Golang on Raspberry PI (Easiest)

golang Jul 06, 2020

I have seen several posts out there about installing Golang on a Raspberry PI. It looks like because of how the Golang developers tag things both on Github and on their downloads page there is no easy way for anyone to keep their instructions up to date with the "latest" release. So here are a few simple commands that should always download the latest (not beta) release of the Golang binary distribution for a Raspberry PI. I also included the commands to install it and set up your shell to use it.

Find the lastest release version tag, download the pkg, and install it

export GOPKG="$(curl -s https://api.github.com/repos/golang/go/git/matching-refs/tags/go | grep ref | grep -v url | grep -v beta | tail -1 | awk -F\/ {' print $3 '} | sed 's/",//')"
wget https://golang.org/dl/$GOPKG.linux-armv6l.tar.gz
sudo tar -C /usr/local -xzf $GOPKG.linux-armv6l.tar.gz
rm $GOPKG.linux-armv6l.tar.gz

Setup the shell

# for zsh
echo PATH=$PATH:/usr/local/go/bin >> $HOME/.zshrc
echo GOPATH=$HOME/golang >> $HOME/.zshrc
source $HOME/.zshrc

Dave York

Father and computer nerd.

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Background Photo by Guido Coppa on Unsplash