How to Install Latest Version of Go on the Raspberry Pi 5
Introduction
So finally I got my hands on the latest version of Raspberry Pi 5 and after the initial setup decided to build an Air Quality Monitor using it. For some reason decided to write the interface using Go.
Installing the latest version of go should be as simple as apt install but unfortunately the latest version is not available in the apt repo. You can check this by running
apt policy golang
The current version of Go is 1.21 as of writing this, but the one available on apt is 1.19.
Download the latest version from go website
Please copy the link for the latest version of Go , from Go download page.
Checking for the right version
Please select the arm64 version if you are running the 64 bit OS or download armv6l version if you are running 32 bit OS. A quick way to check it is by running
uname -m
If the output says aarch64 GNU/Linux in the output string its 64 bit else if its armv7l GNU/Linux its a 32 bit OS.
I have a 64 bit OS so will be using it. To download execute
wget https://go.dev/dl/go1.21.4.linux-arm64.tar.gz
Extract the downloaded file
Once the download finishes, extract it to /usr/local
sudo tar -C /usr/local -xzf go1.21.4.linux-arm64.tar.gz rm go1.21.4.linux-arm64.tar.gz
Configure Environment variables
Now as the last step we’ll add the go binary to the PATH variable and add the value for GOPATH variable. To do this open your ~/.profile in a text editor(nano, vi, vim etc). I have vim installed to, used the following command
vim ~/.profile
Append the following line in the file and save it
PATH=$PATH:/usr/local/go/bin GOPATH=$HOME/go
Now you can refresh your shell using the following command or open a new terminal
source ~/.profile
Test your version
To test if everything got configured correctly simply execute go version if all worked fine you should get an output string something like go version go1.21.1 linux/arm64. cheers!
1 comment
Leave a Reply Cancel reply
This site uses Akismet to reduce spam. Learn how your comment data is processed.
Thank you!