How to install golang on Raspberry PI

  • 17 March 2017
  • ADM

 

How to install golang on Raspberry PI - images/logos/golang.jpg

 

This post if about installing the GO programming language. Follow the Raspberry Pi 3 first remote startup for simple Raspberry PI setup.

Install using apt-get

To install the Raspberry PI version using apt-get run the following command line:

pi@raspberrypi:~ $ sudo apt-get install golang

Note: this will take a few minutes to install.

After installation, to check the version number run the following command line:

pi@raspberrypi:~ $ go version

The output:

go version go1.3.3 linux/arm

The disadvantage installing this version is that the latest version is not available (currently 1.7.3).

Install from precompiled version

If you want to install the latest precompiled version following the next steps are needed.

Step1 - download binary files

To download the arm binary file run the following command line:

pi@raspberrypi:~ $ wget https://storage.googleapis.com/golang/go1.7.3.linux-armv6l.tar.gz

Step2 - Extract into usr/local

Run the following command line:

pi@raspberrypi:~ $ tar -C /usr/local -xzf go1.7.3.linux-armv6l.tar.gz

Step3 - Add to the path

Add the go/bin folder to the $PATH variable:

pi@raspberrypi:~ $ export PATH=$PATH:/usr/local/go/bin

Add the export line to the $HOME/.profile to be available after a restart.

Step4 - Check the installation version

Run the following command:

pi@raspberrypi:~/go/bin $ go version
go version go1.7.3 linux/arm

If you want to see other tutorials for RaspberryPi check the RaspberryPI tutorials.