Push rejected, failed to compile Go app. Error when deploying Go to Heroku

About the error

I wanted to deploy the API made with Go to Heroku, git push heroku main I gave a command

!     Push rejected, failed to compile Go app.
!     Push failed

Failed with the above error.

The solution

Looking back at the log,

-----> 
 !!    The go.mod file for this project does not specify a Go version
 !!    
 !!    Defaulting to go1.12.17
 !!    
 !!    For more details see: https://devcenter.heroku.com/articles/go-apps-with-modules#build-configuration
 !!    
-----> New Go Version, clearing old cache

There was a description like. At first I didn't think this was the cause, so I left it alone, but I decided to give it a try.

If you look it up, you can use go.mod to specify the go version on Heroku.

go.mod


module xxxx

// +heroku goVersion go1.15      <--add to
go 1.15

It seems that it needs to be described as. After rewriting and pushing again, I was able to deploy successfully.

Recommended Posts

Push rejected, failed to compile Go app. Error when deploying Go to Heroku
Articles to see if rejected when git push heroku master on Heroku
Solution for errors when deploying to Heroku
[Django] Error encountered when deploying heroku Part 2
When I try to push with heroku, it doesn't work
I get [Error 2055] when trying to connect to MySQL on Heroku
What to do if package installation fails when deploying to heroku
How to deal with errors when installing whitenoise and deploying to Heroku
When WSL Distro fails to start (error: "WslRegisterDistribution failed with error: 0x800706be.")