ArrowLeft Icon

Installing the Latest Version of Golang on Your Raspberry Pi

📆 · ⏳ 3 min read · · 👀


Golang, or Go, is a modern and efficient programming language used for a variety of applications, including web development, system programming, and network programming. With its simple syntax and high-performance runtime, it’s no wonder that it has become a popular choice for developers.

If you have a Raspberry Pi and want to start developing in Go, you’ll need to install the latest version of the Golang runtime. In this article, we’ll guide you through the installation process, step by step.


The first step is to update your Raspberry Pi’s package index and install the dependencies required for the Golang runtime:

Terminal window
sudo apt update && sudo apt install -y wget git build-essential

Next, download the latest version of Golang:

Terminal window

Replace [version] with the latest version number of Golang. You can find that on their downloads ↗️ page.

Note: Recently Raspberry Pi have started support for 64-bit OS. If you are using 64-bit OS, then you need to download the linux-arm64.tar.gz file instead of linux-armv6l.tar.gz. So make sure you replace the file name in the above command.

Then, extract the archive:

Terminal window
tar -xvf go[version].linux-armv6l.tar.gz

Move the extracted folder to ~/.local/share:

Terminal window
mv go ~/.local/share

Set up the environment variables for Golang:

This depends based on the shell you are using, you can verify it using basename $SHELL command, it will output zsh, bash or fish.

Based on your shell, you need to update the correct config file for it. Let’s see the example of updating for zsh

Terminal window
echo 'export GOPATH=$HOME/.local/share/go' >> ~/.zshrc
echo 'export PATH=$HOME/.local/share/go/bin:$PATH' >> ~/.zshrc
source ~/.zshrc

For bash, the default config file would be .bashrc and for fish it would be .config/fish/

One Script for Everything

To summarise, we can put all of this into a single shell script to download and setup golang on armhf architecture.

VERSION=1.21.1 # pick the latest version from
ARCH=armv6l # arm64 for 64-bit OS
## Download the latest version of Golang
echo "Downloading Go $VERSION"
echo "Downloading Go $VERSION completed"
## Extract the archive
echo "Extracting..."
tar -C ~/.local/share -xzf go$VERSION.linux-$ARCH.tar.gz
echo "Extraction complete"
## Detect the user's shell and add the appropriate path variables
SHELL_TYPE=$(basename "$SHELL")
if [ "$SHELL_TYPE" = "zsh" ]; then
echo "Found ZSH shell"
elif [ "$SHELL_TYPE" = "bash" ]; then
echo "Found Bash shell"
elif [ "$SHELL_TYPE" = "fish" ]; then
echo "Found Fish shell"
echo "Unsupported shell: $SHELL_TYPE"
exit 1
echo 'export GOPATH=$HOME/.local/share/go' >> "$SHELL_RC"
echo 'export PATH=$HOME/.local/share/go/bin:$PATH' >> "$SHELL_RC"
## Verify the installation
if [ -x "$(command -v go)" ]; then
INSTALLED_VERSION=$(go version | awk '{print $3}')
if [ "$INSTALLED_VERSION" == "go$VERSION" ]; then
echo "Go $VERSION is installed successfully."
echo "Installed Go version ($INSTALLED_VERSION) doesn't match the expected version (go$VERSION)."
echo "Go is not found in the PATH. Make sure to add Go's bin directory to your PATH."
## Clean up
rm go$VERSION.linux-$ARCH.tar.gz

Before running the script, make sure you make it executable.

You can do it like this chmod +x Replace with whatever name you gave to the file.

That’s it, now run the file with ./ and it will install and setup golang on your system.


By following these simple steps, you should now have the latest version of Golang installed on your Raspberry Pi. Whether you’re a seasoned Go developer or just starting out, the Raspberry Pi is a great platform for developing in Golang.

With its low cost, small form factor, and powerful hardware, it provides a great way to learn and experiment with the Go programming language.

EnvelopeOpen IconStay up to date

Get notified when I publish something new, and unsubscribe at any time.

Need help with your software project? Let’s talk

You may also like

  • # homelab

    AdGuard Home + Tailscale = Erase Ads on the Go

    Fed up with pesky online ads? In this blog, I'll show you how a dynamic duo, AdGuard Home and Tailscale, can give you ad-free browsing anytime, anywhere. It's a technical adventure that's worth every click.

  • # homelab

    How I Safeguard Essential Data in My Homelab with Off-site Backup on Cloud

    Data is the lifeblood of my homelab, and losing it would be a nightmare. Join me in exploring my backup strategy, featuring rclone and systemd, to keep my databases, vital data, and even passwords safe and sound in the cloud.

  • # homelab

    Should You Self-Host Password Managers On-Premises?

    The idea of self-hosting your password manager on-premises has been a hot topic in the homelab community. But is it worth the effort and potential risks? I've gathered insights from experienced self-hosters to help you decide.