Reputation: 179
I am deploying an application through Heroku.
I do git push heroku master
And I get this error:
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Go app detected
remote: -----> Fetching stdlib.sh.v8... done
remote: ----->
remote: Detected go modules via go.mod
remote: ----->
remote: Detected Module Name: go-getting-started
remote: ----->
remote: !! The go.mod file for this project does not specify a Go version
remote: !!
remote: !! Defaulting to go1.12.7
remote: !!
remote: !! For more details see: https://devcenter.heroku.com/articles/go-a
ps-with-modules#build-configuration
remote: !!
remote: -----> New Go Version, clearing old cache
remote: -----> Installing go1.12.7
remote: -----> Fetching go1.12.7.linux-amd64.tar.gz...
remote: gzip: stdin: not in gzip format
remote: tar: Child returned status 1
remote: tar: Error is not recoverable: exiting now
remote: ! Push rejected, failed to compile Go app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to autoattack.
I think it's a problem with the new Go version and for this reason I want to use a previous one.
This is my go.mod file:
module go-getting-started
go 1.12
...
I tried to change go 1.12
to go 1.11
but it doesn't work.
Upvotes: 16
Views: 9573
Reputation: 2222
You could add a directive // +heroku goVersion go1.11
in your go.mod
file.
module somemodule
// +heroku goVersion go1.11
go 1.11
require (
// ...
)
Then it should look like this.
remote: Detected go modules via go.mod
remote: ----->
remote: Detected Module Name: somemodule
remote: ----->
remote: -----> New Go Version, clearing old cache
remote: -----> Installing go1.11
Documentation: https://github.com/heroku/heroku-buildpack-go#go-module-specifics
Go Module Specifics
You can specify specific package spec(s) via the
go.mod
file's// +heroku install
directive (see below).
// +heroku goVersion <version>
: the major version of go you would like Heroku to use when compiling your code. If not specified this defaults to the buildpack's [DefaultVersion].
Upvotes: 49
Reputation: 418435
You can set the Go version to be used by adding a GOVERSION
environment variable. You can do this on the Heroku Settings page of your project.
You may set the previous (working) revision by adding GOVERSION=go1.12.6
.
This is documented at Heroku Go Support: Go versions:
If you need to select a specific minor revision (e.x. go1.8.7) for any reason you will need to hand edit the appropriate metadata file or set the
$GOVERSION
environment variable...
Upvotes: 11