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:
Next, download the latest version of Golang:
[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.gzfile instead of
linux-armv6l.tar.gz. So make sure you replace the file name in the above command.
Then, extract the archive:
Move the extracted folder to
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
Based on your shell, you need to update the correct config file for it. Let’s see the example of updating for zsh
For bash, the default config file would be
.bashrc and for fish it would be
To summarise, we can put all of this into a single shell script to download and setup golang on armhf architecture.
Before running the script, make sure you make it executable.
You can do it like this
chmod +x install-go.sh. Replace
install-go.sh with whatever name you gave to the file.
That’s it, now run the file with
./install-go.sh 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.