Moncef Belyamani

Coding, productivity, and Mac automation tutorials for beginners and beyond.

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):

1
2
3
$ 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:

1
$ sudo go get code.google.com/p/go-tour/gotour

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

1
package code.google.com/p/go-tour/gotour: mkdir /usr/local/go/src/pkg/code.google.com: permission denied

5) Launch the Tour:

1
$ gotour

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

1
2
2012/07/25 18:12:15 Serving content from /usr/local/go/src/pkg/code.google.com/p/go-tour
2012/07/25 18:12:15 Open your web browser and visit http://127.0.0.1:3999/

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

1
2
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.