Installing golang on Rocky Linux
 golangPerhaps more for my benifit but here lies instructions to install golang on a Raspberry PI running Rocky Linux.
Installing
sudo dnf install -y tar curl
For me, Rocky 9 on the PI did not come with tar pre-installed. Make sure you have these two tools available:
sudo dnf install -y \
curl \
tar
Download the binary from the official golang site:
$ curl https://go.dev/dl/go1.24.3.linux-arm64.tar.gz --output /tmp/go.tar.gz --location
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 75 100 75 0 0 384 0 --:--:-- --:--:-- --:--:-- 386
100 71.3M 100 71.3M 0 0 27.7M 0 0:00:02 0:00:02 --:--:-- 33.3M
For those unfamiliar with
curl
:
--output /tmp/go.tar.gz
tellscurl
to put the binary at the given filepath--location
tellscurl
to follow redirects
Verify the checksum matches the expected value on https://go.dev/dl/:
$ sha256sum /tmp/go.tar.gz
a463cb59382bd7ae7d8f4c68846e73c4d589f223c589ac76871b66811ded7836 /tmp/go.tar.gz
Extract the contents to /usr/local/go
:
tar -zxvf /tmp/go.tar.gz -C /usr/local
Add go to the path on boot:
echo 'export GOROOT=/usr/local/go' | tee -a /etc/profile.d/golang.sh
echo 'export PATH=$PATH:/usr/local/go/bin' | tee -a /etc/profile.d/golang.sh
echo 'export PATH=$PATH:$(go env GOPATH)/bin' | tee -a ~/.bash_profile
Apply those changes:
source /etc/profile.d/golang.sh
source ~/.bash_profile
Check the installation was successful and the go command is discoverable on the path.
$ go version
go version go1.24.3 linux/arm64
Some go libraries require a C compiler, this can be added with:
dnf install gcc-c++
Upgrading
Repeat the curl
through tar
extraction stage with the link of the new version. Simple.
Uninstalling
Clean-up cached files:
go clean -modcache
go clean -cache
go clean -fuzzcache
Remove the env var configurations:
rm /etc/profile.d/golang.sh
sed -i '/go env/d' ~/.bash_profile
A restart is required to reset the env vars that have been changed.
Finally remove the golang binaries:
rm /usr/local/go -r