Deploy a Go API to Heroku

Deploying your code to Heroku has always been easy - that’s one of the best selling points. Creating and deploying an app from the CLI is a cinch with heroku apps:create and git push heroku master. It’s just as easy from the Dashboard. With the Heroku Button, it’s even easier to get a piece of shared code up-and-running for the first time with a couple of clicks. Try it below or give our version a whirl before we take a quick peek at this Go API that fetches a random pun for a keyword.


In this API, we use nothing but the standard library to make a call to RhymeBrain’s rhyming words API to get words that rhyme with the keyword. Then we match the rhyming words against a list of phrases from various sources. To generate puns we swap out the keyword for the rhyming words in those phrases. A random generated pun is served as JSON. Check out the code.

The whole thing takes about 140 lines of code. It’s simple and shows off the power of Go’s standard library: reading files, making API requests, and serving HTTP without any external dependencies.

By combining Go’s efficiency with Heroku’s power and ease-of-use, we are able to quickly and easily build and deploy performant tools like our pun API.

P.S. A couple of go puns we liked from the API:

  • There is nothing either good or bad, but thinking makes it Go.
  • It takes one to Go one.
  • You Go what to do
  • Golang of Four