Install Go on Raspbian

A `golang` package exists, but if you would like to install the latest (currently 1.2), you will need to download the source and compile it.

Note: I used Dave Cheney's post as a guide and I highly recommend you read that for additional notes. I am posting this version with subtle differences to document what worked for me.

This was all done on a fresh Raspbian image loaded onto a 16GB SD Card.

1. Configure Raspbian

By running df -h you will notice that there is only 2 GB allocated.

Run raspi-config and expand the root partition to use the entire disk.

Also, go to the advanced section and set the memory split to 240. As Dave explains it, by default, memory is allocated 50/50 to ARM and the GPU. The screenshots in Dave's post shows the UI providing preset split values with memory split at the top menu level. In my configuration, memory split was under the Advanced menu, and it takes a numeric value for the amount to allocate to the GPU. Set this to 16.

$ sudo raspi-config 

Now run a df -h to confirm you have the full (or close to it) memory available.

2. Next, update apt and install gcc & shared libraries

$ sudo apt-get update
$ sudo apt-get install -y gcc libc6-dev

3. Download the source of the go version you would like to install. (Currently, the latest is 1.2)

$ wget https://go.googlecode.com/files/go1.2.src.tar.gz
$ tar -zxvf go1.2.src.tar.gz

4. Build it
You can run the test suite and build with ./all.bash. This uses a lot of memory and may require you to setup swap. (Dave Cheney's post covers this). I opted to just build it with ./make.bash. Going the test suite direction will take a while longer, but even without it, it took over a 1/2 hour.

$ cd go/src
$ ./all.bash

5. Configure
Now all you need to do is create the gocode directory, and set the go paths.

$ mkdir ~/gocode
$ echo "export GOOPATH=\$HOME/gocode" >> ~/.profile
$ echo "export GOROOT=\$HOME/go" >> ~/.profile
$ echo "export PATH=\$PATH:\$GOROOT/bin" >> ~/.profile
$ source ~/profile