Installing gotour on OSX

I recently started learning Go, and started out by following the tour on the golang site. The tour’s pretty good, and so when I left work and wanted to continue it on the train I decided to install it locally so I could work offline.

Unfortunately, Go uses Mercurial to power it’s code downloader. I didn’t have it installed, so I tried to install it with:

brew install hg

This didn’t work, and I was presented with the following error:

Python headers are required to build Mercurial but weren't found in /System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/Python.h

To get the required file, I needed to install the Xcode developer tools:

xcode-select --install

Once I’d done that, I could install Mercurial and Go without any issues:

brew install hg go

Next, I downloaded the tour to my local machine using go get.

go get

Finally, I set up a few required paths by adding the following to the bottom of my .zshrc/.bashrc:

export GOPATH=~/gocode
export PATH=~/gocode/bin:$PATH

Now, we’re good to go (no pun intended). Just run the following to start the tour:


March 09, 2014

How To