Installed Go in Mac OS 10.5

Yes, I know it: it is easy. But I will be doing a wipe and reinstall of my MacBook, and when I need to reinstall everything I want a place to check for the steps I did. I found almost all tips needed here.

The first step is checking for Mercurial (wikipedia) in your system. Open a terminal and type
hg version
If your terminal complains about command not found, you don't have Mercurial installed. You have to install it, but prior to it you need to check your Python version. In your terminal,
python -V
will tell you which version you have. You'll have it installed, as Mac OS has it by default. In the improbable case you don't, you can install from here as a standard dmg-pkg Mac OS install. Anyway, it is a good idea to update it. After you have Python installed, you can install Mercurial from here. Beware, you need to install a version suited to your Mac OS version and Python version. If in doubt, upgrade Python and install the latest available Mercurial.

I forgot to mention that you need XCode, and all the usual development tools for Mac OS (gcc and the like). But I guess you already have all this installed if you are interested in installing go. If not, they are in your companion CD for Mac OS.

After you have all this requirements, you are ready to download the latest version of Go from the Google repositories. Open your favourite editor and open ~/.bash_profile. Add the following lines to its end
export GOROOT=$HOME/go
export GOOS=darwin
export GOARCH=386
export GOBIN=$HOME/bin
Now, to reload your bash profile (without needing to open a new terminal window) type
source ~/.bash_profile
All these variables should now be working correctly. The time to fetch go has arrived! Be sure that you don't have a ~/go directory prior to this step, as this could wipe or corrupt data in that directory.
hg clone -r release https://go.googlecode.com/hg/ $GOROOT
This step can take around one or two minutes. Once you are done, you need to create a ~/bin directory and make it executable, if it doesn't exist. If this is the case,
mkdir ~/bin
chmod 755 !$
Just one step left
cd $GOROOT/src
This will take a while and write a lot of information in your terminal window. If everything worked smoothly, you will get a line saying
3 known bugs; 0 unexpected bugs
or something along these lines.

For me something didn't work perfect the first time. The problem is that I left it compiling and walked away. When I came back I saw some error related to http tests. I Tried again later, without walking away: I have the Mac OS firewall set on ask. As I didn't answer when prompted if some test program could connect to the Internet, the connection broke and the networking tests didn't proceed. If you also have this firewall setting, you will have to allow 5 or 6 programs. I recommend that you turn off the firewall while compiling, remember to reset it afterwards.

Now, you should have a nice working Go environment. Check if the compiler and linker are to be found
which 8g
which 8l
If you want to test if it works, you can find a sample hello world program here (Go homepage).

I hope this helped your process of installing (and learning) this language.

Related posts:
8 reader reasons for re-inventing the wheel as a programmer
Approximating images with randomly placed translucent triangles
8 reasons for re-inventing the wheel as a programmer
9 programming books I have read and somewhat liked...
C code juicer: detecting copied programming assignments
Written by Ruben Berenguel