Go

Requirements

The Go buildpack is used when an application meets one of the following requirements:

  1. has a Godeps/Godeps.json file, identifying the application as being managed by godep;
  2. has a vendor/vendor.json file, identifying the application as being managed by govendor;
  3. has a src directory, which has sub directories, contains one or more .go files, identifying the application as being managed by gb.

Define a Procfile

Use a Procfile, a text file in the root directory of your application, to explicitly declare what command should be executed to start your app.

The Procfile in the example app you deployed looks like this:

web: bin/myproject

The command used here, bin/myproject is the compiled binary of the getting started app. The build process installs compiled binaries into the app's ~/bin directory.

Declare dependencies

go.mod example:

module github.com/heroku/go-getting-started

go 1.12

require (
    github.com/gin-gonic/gin v0.0.0-20150626140855-4cc2de6207f4
    github.com/heroku/x v0.0.0-20171004170240-705849e307dd
    github.com/manucorporat/sse v0.0.0-20150604091100-c142f0f1baea // indirect
    github.com/mattn/go-colorable v0.0.0-20150625154642-40e4aedc8fab // indirect
    github.com/mattn/go-isatty v0.0.0-20150814002629-7fcbc72f853b // indirect
    github.com/stretchr/testify v1.3.0 // indirect
    golang.org/x/net v0.0.0-20150629084131-d9558e5c97f8 // indirect
    gopkg.in/bluesuncorp/validator.v5 v5.9.1 // indirect
)

The go.mod file is used by Go tool and specifies both the dependencies that are required to build your application and the build configuration used to compile the application.

When an app is deployed, Backery reads this file, installs an appropriate Go version and compiles your code using go install . .