How to Deploy a Go App to Heroku

Deploy a Go app to Heroku by creating a Procfile, setting the Go buildpack, and pushing your code via Git.

Deploy your Go app to Heroku by adding a Procfile and using the Heroku Go buildpack.

  1. Create a file named Procfile in your project root with the content web: go run main.go.
  2. Initialize a Git repository and commit your code with git init and git add . followed by git commit -m "initial commit".
  3. Log in to Heroku with heroku login.
  4. Create a new Heroku app with heroku create your-app-name.
  5. Set the Go buildpack with heroku buildpacks:set heroku/go.
  6. Push your code to deploy with git push heroku main.