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 code.google.com/p/go-tour/gotour

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:

gotour

Michael is a polyglot software engineer, committed to reducing complexity in systems and making them more predictable. Working with a variety of languages and tools, he shares his technical expertise to audiences all around the world at user groups and conferences. You can follow @mheap on Twitter

Thoughts on this post

Leave a comment?

Leave a Reply