I'd like to use the Pis with Raspbian to run Go code. For this, I like to write an easy and fast setup guide from the point you erase the SD card. During the development, I installed Go on the Pis with this guide. It has some deficiencies but works fine. My only problem is, that we have to install mercurial just for cloning the sources: hg clone -u default https://code.google.com/p/go $HOME/go
The installation of mercurial on Pi is really slow. I'd like to ask how to work it around (It's not a problem if I don't build it from source.)
There's already a go compiler in, e.g., raspbian, which you can find with apt-cache search golang
. This looks to be version 1.0.2.
The site you linked has pre-compiled tarballs of 1.3.3 available for the pi. You just need to download the appropriate one -- it is clearly indicated.
Put the tarball in /usr/local
and:
tar -xzf go.1.3.3.linux-arm~multiarch-armv6-1.tar.gz
This will create a go
directory; the top level README refers to the contents as the go source, but if you look in the bin
directory, you'll see the precompiled go
executable there. To make this generally useful you'll have to get that into $PATH
. Add a file to /etc/profile.d
called go.sh
with one line:
export PATH=/usr/local/go/bin:$PATH
If there's already a go installed, this will now supersede that. I'm not a go user so I don't know if much more is necessary, but if you look in the doc
directory there's lots of stuff there, including an install.html
file.
As of Go 1.6 (February 2016), an official ARMv6 package is available for download. So, if your Raspberry Pi has ARMv6 or v7 (see cat /proc/cpuinfo | grep ARM
), then just do something like:
wget https://storage.googleapis.com/golang/go1.6.2.linux-armv6l.tar.gz
sudo tar -xzf go1.6.2.linux-armv6l.tar.gz -C /usr/local
sudo chgrp -R staff /usr/local/go
export GOROOT=/usr/local/go
export PATH="$PATH:$GOROOT/bin"
The above is fast, and less cumbersome than building 1.5+ from source:
To build Go 1.x, for x ≥ 5, it will be necessary to have Go 1.4 (or newer) installed already, in $GOROOT_BOOTSTRAP.
Should be as simple as
sudo apt-get install mercurial
there are other mercurial packages that can be found via
sudo apt-cache search mercurial