Go

Helion Stackato supports deploying Go applications (golang) using the buildpack framework.

Local Install

To build Go code, install it locally using one of the Go packages.

Deployment

The following is a basic deployment setup based on the "Hello World" Go sample application.

To deploy a Go application on Helion Stackato, you need the following files:

  • app.go
  • Procfile
  • .godir
  • manifest.yml

app.go

The Go buildpack recognizes applications by looking for a Go source file anywhere in the repository:

package main

import (
        "fmt"
        "log"
        "net/http"
        "os"
)

func main() {
        http.HandleFunc("/", hello)
        err := http.ListenAndServe(":"+os.Getenv("PORT"), nil)
        if err != nil {
                log.Fatal("ListenAndServe:", err)
        }
}

func hello(w http.ResponseWriter, req *http.Request) {
        fmt.Fprintln(w, "hello, world!")
}

Procfile

To run the web process, you need to declare the command to be used. In this case, execute your Go program. Use the Procfile to declare how your web process type is run:

web: server

.godir

The go tool uses the directory name of your project to name executables and determine package import paths. In your project's root directory, create a file called .godir, containing the path from $GOPATH/src to the root directory:

example.com/hello

manifest.yml

This file is optional because Helion Stackato detects the framework automatically. However, you can still use manifest.yml to set the app name, to configure settings, to create services, and so on. (For more information, see Manifest.yml Options):

name:
        hello-go