How to install the Go Tour on your Mac

After reading an interesting article describing how the SoundCloud dev team uses Go, I decided to learn more about this new language. I started by visiting the Tour, and followed the advice to run it locally. Unfortunately, the instructions on the page are missing a few key steps. Here's how I got the Go Tour installed on my Lion machine:

1) Download the Go package installer for Mac OS X and install Go

2) Restart Terminal

3) Install Mercurial with Homebrew (if you don't have Homebrew installed, follow my guide for setting up a development environment on a Mac):

$ brew update   # make sure Homebrew is up to date
$ brew doctor   # make sure your system is raring to brew
$ brew install mercurial    # or brew install hg

4) In Terminal, run the following command:

$ sudo go get

Without sudo, you will probably get this permission denied error:

package mkdir /usr/local/go/src/pkg/ permission denied

5) Launch the Tour:

$ gotour

If everything went well, you should see the something like this:

2012/07/25 18:12:15 Serving content from /usr/local/go/src/pkg/
2012/07/25 18:12:15 Open your web browser and visit

6) Open the Tour in your browser by going to and learn about neat Go features, such as quick initialization of variables, even if they're not of the same type:

var x, y, z int = 1, 2, 3
var c, python, java = true, false, "no!"

Mountain Lion Update: If you successfully installed Go on Lion, and then upgraded to Mountain Lion, you will have to repeat steps 1 and 2 before being able to run gotour.