Installing Go on Mac OS X

Frederic Cambus February 06, 2012 [Golang]

Installing Go on a Mac OS X system is a pretty easy process. In order to do so, you will need to have Xcode and Mercurial installed; it is possible to download precompiled binary packages from the official Mercurial site, but as I have Homebrew installed on this system, that's what I've been using instead.

In your home directory, type the following command to clone the Go repository:

hg clone -u release go

We then compile everything by invoking the following commands:

cd go/src

On my system, the whole operation is quite fast and takes approximately three minutes to complete (compilation + all unit tests).

real	3m10.309s
user	2m48.050s
sys		0m41.652s

Finally, you need to set a few environment variables in your .bash_profile file:

export GOROOT=$HOME/go
export GOOS=darwin
export GOARCH=amd64
export GOBIN=$GOROOT/bin

Congratulations, Go is now installed on your system and you're ready to start working with it!