Install Go on Raspberry Pi

February 26, 2017

Go Programming language is becoming popular in IoT sphere as well. I am very fascinated by Go powered robotics/IoT framework Gobot and planning to play with it using my RPi.

This post explains how to install Go on Raspberry Pi.

My RPi (2 Model B) shows it has ARMv7 processor.

$ uname -m
armv7l

Go’s current stable version 1.8 has official ARMv6 build available for download Since ARMv7 compatible CPU can execute ARMv6 code, let’s download Go 1.8 ARMv6 build and install it.

download go

# Download archive
$ wget https://storage.googleapis.com/golang/go1.8.linux-armv6l.tar.gz

# Extract it into /usr/local. It will create a Go tree in /usr/local/go
$ sudo tar -C /usr/local -xzf go1.8.linux-armv6l.tar.gz

# Add /usr/local/go/bin to the PATH environment variable.
# You can do this by adding a line to your /etc/profile
# (for a system-wide installation) or $HOME/.profile as shown below
$ echo 'export PATH=$PATH:/usr/local/go/bin' >> $HOME/.profile

# Above PATH setting will work when we re-login. Export it in current session as well.
$ export PATH=$PATH:/usr/local/go/bin

If all above steps worked fine, you will be able to execute go commands. Let’s check version.

$ go version
go version go1.8 linux/arm

Sweet! Follow this guide to test the new installation by building ‘Hello World!’ program.

Note: You will soon be installing external libraries/packages using go get. The go get fetching of source code is done by using one of the tools mentioned here and it is expected to be found on your system. I installed git from that list using below command

# Using apt-get, since I have `Raspbian` installed on my RPi
$ sudo apt-get install git



comments powered by Disqus