Docs menu

Go on Primcloud

How Primcloud detects a Go app, builds its binaries, and works out its process types.

On this page

Detection#

Primcloud builds your app as Go when the root of your repo has a go.mod. Only Go modules are supported; dep, godep, govendor, and glide aren't.

The build#

The build installs the Go version from go.mod (see Runtime versions) and downloads your modules, verifying them against go.sum. If your repo has a vendor/modules.txt, your vendored modules are used instead.

It then runs:

Terminal
go install -tags heroku <package> [<package>...]

The packages are the ones named by a // +heroku install line in go.mod, or otherwise every main package in your module. Each binary is on the PATH under its package name.

The heroku build tag is always set, so files marked //go:build heroku are included and files marked //go:build !heroku are left out.

Any GO-prefixed secrets you set are visible to the build, which lists them in a warning when it starts, since they can change how your app builds.

The Go toolchain, downloaded modules, and compiled packages are reused from the previous build when they haven't changed, so later builds are faster. Only your binaries ship with your app, not the Go toolchain.

Process types#

A Procfile decides your processes; see Formations. Without one, every binary becomes a process type:

  • Each is named after the last part of its package's import path and runs the binary of that name. example.com/myapp/cmd/worker becomes worker.
  • If a package is named web, it's your web process. Otherwise the first package also runs as web, so your app always has one.

Your web process must listen on $PORT (5000). Nothing passes the port to your binary, so read it in your code:

port := os.Getenv("PORT")
if port == "" {
    log.Fatal("$PORT must be set")
}
router.Run(":" + port)

Other process types don't get a PORT. No Go-specific environment variables are set at runtime; your processes get PORT on web and your secrets.