This document describes how to install Go in Raspberry OS
0. Overview
1. Contents
2. Syntax
3. Update the package repository
4. Upgrade the installed packages
5. Check what is available
6. Installing using apt
7. Installing using the download page
99. References
[button] - is a button on the screen with the text 'button' on it.
InputField: - is a field labeled 'InputField:', where you can enter text.
<PlaceHolder> - a placeholder to be replaced with your own text (without the '<' and '>').
[v] Label1 - ensure there is a check mark in front of the label 'Label1'
[x] Label2 - ensure there is an 'x' in the check box in front of the label 'Label2'
1/3 - step 1 of in total 3 steps
$ - prompt for a regular user
# - prompt for the root user (system administrator)
host $ - prompt for the regular user on the host system
host # - prompt for the root user on the host system
container $ - prompt for the regular user in the container
container # - prompt for the root user in the container
$ sudo apt update
$ sudo apt upgrade
$ apt policy golang
golang:
Installed: (none)
Candidate: 2:1.11~1+b6
Version table:
2:1.11~1+b6 500
500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
If the target release has not been specified then APT simply assigns priority 100 to all installed package versions and priority 500 to all uninstalled package versions.
For more information:
$ man apt_preferences
In contrast to the golang page:
https://golang.org/dl/
Current version here is go.1.17.src.tar.gz
$ sudo apt install golang
pi@raspberrypi: $ apt policy golang
golang:
Installed: 2:1.11~1+b6
Candidate: 2:1.11~1+b6
Version table:
*** 2:1.11~1+b6 500
500 http://raspbian.raspberrypi.org/raspbian buster/main armhf Packages
100 /var/lib/dpkg/status
pi@raspberrypi: $ go version
go version go1.11.6 linux/arm
pi@raspberrypi: $
You might have noticed, that the go package available through apt is not as up to date as the one available under:
A Raspberry Pi is build around an ARM CPU. So when looking for the latest Go version, you should look for packages ending in:
..armv*.tar.gz
To see what type of ARM processor your Raspberry Pi is using, use the following command:
$ uname -m
At the time of writing this document, the Raspberry Pi system shows a machine name of:
armv7l
Furthermore, the latest release of go is version 1.17. Create a directory and download the latest version to that directory:
$ mkdir -p Go/src $ cd Go/src $ wget https://dl.google.com/go/ Replace >my-package> with the version you want to download. E.g. go1.17.linux-armv6l.tar.gz
Extract the tar-ball with:
sudo tar -C /usr/local -xzf go1.17.linux-armv6l.tar.gz
Add Go to your path and set the GOPATH variable, by editing your ~/.profile and adding the following line:
> if [ -d "/usr/local/go/bin" ] ; then
> PATH=$PATH:/usr/local/go/bin
> GOPATH=$HOME/go
> fi
The GOPATH variable is used to find the go programs you have created.
https://www.jeremymorgan.com/tutorials/raspberry-pi/install-go-raspberry-pi/