On Heroku projects are compiled / built using so called buildpacks. Specific buildpacks are created for projects using different languages. For Go projects there exists the heroku/go
which knows how to get, compile and build Go projects, including getting their dependencies automatically as part of the build process.
The buildpack selection can happen either manually or automatically. You see the error you posted because you have not set any buildpacks manually, and automatic detection failed for you. See reasons below.
Manual buildpack selection
For manual selection, download the Heroku CLI, and execute the following command:
heroku buildpacks:set heroku/go
Note: if you're using heroku
cli for the first time, you may need to login using heroku login
. Also if your app is not selected by default, you may specify it using the -a
or --app
argument, e.g.:
heroku buildpacks:set heroku.go -a yourappname
To see selected buildpacks, execute the heroku buildpacks
command.
Automatic buildpack detection
Just because a project is using the Go language, the heroku/go
buildpack does not get selected automatically.
The actual detection whether heroku/go
should be used is done by the script heroku-buildpack-go/bin/detect
, the detection logic is:
if test -f "${build}/Godeps/Godeps.json" || # godeps
test -f "${build}/vendor/vendor.json" || # govendor
test -f "${build}/glide.yaml" || # glide
(test -d "${build}/src" && test -n "$(find "${build}/src" -mindepth 2 -type f -name '*.go' | sed 1q)") # gb
then
echo Go
else
exit 1
fi
So basically the Go language is detected and heroku/go
buildpack is selected automatically if one of the following file is present in your project:
-
Godeps/Godps.json
; used by godep
-
vendor/vendor.json
; used by govendor
-
glide.yaml
; used by glide
-
src/*/*/**/*.go
; used by GB
Further reading
Official articles about working with Go and Heroku:
Getting Started on Heroku with Go
Heroku Go Support