Raspberry Pi

2 Easy Methods to Install Go on Raspberry Pi

Go is a fast, reliable, and efficient programming language developed by Google. The syntax of the Go language is like C but is more stable and memory efficient than C. You can use this language to build and develop concurrent and scalable software.

This article will show different methods to install Go on your Raspberry Pi system.

Install Go on Raspberry Pi

There are two different ways to install Go programming language on a Raspberry Pi system:

Method 1: Install Go from Raspberry Pi Repository

You can easily install Go on Raspberry Pi from its official repository using the following command:

$ sudo apt install golang -y

However, with this method, you won’t be able to install the latest version of Go on your Raspberry Pi system. To confirm the Go version installed using this method, use the following command:

$ go version

Remove Go from Raspberry Pi

You can remove Go from your Raspberry Pi system easily through the following terminal command:

$ sudo apt remove golang -y

Method 2: Install Go from tar.gz File

If you want to install the latest version of, Go language on your Raspberry Pi system, you can use the following steps:

Step 1: Download Latest Go tar.gz File

To download the latest version of Go on Raspberry Pi, head towards the website and download the latest tar.gz file according to your Raspberry Pi version.

Since I am using 32-Bit Raspberry Pi OS, the command will look like this:

$ wget https://go.dev/dl/go1.19.2.linux-armv6l.tar.gz

For 64Bit Raspberry Pi OS, you can download Go tar.gz file through the following command:

$ wget https://go.dev/dl/go1.19.2.linux-arm64.tar.gz

Step 2: Extract the Go Package to Local Folder

To install the Go package to a local folder, you should apply the following command:

$ sudo tar -C /usr/local -xzf go1.19.2.linux-armv6l.tar.gz

Step 3: Configure Path for Go

You must add the path where the Go files are placed and to do that you have to open the following profile:

$ nano ~/.profile

Add the following two lines at the bottom of this file:

PATH=$PATH:/usr/local/go/bin

GOPATH=$HOME/go

Save the file using the “CTR+X” keys and then press “Y”.

Step 4: Update Changes

To update the changes, apply the following command:

$ source ~/.profile

After making the changes, you can confirm the Go version using the following command:

$ go version

Remove Go from Raspberry Pi

To remove Go installed from this method, you should execute the following command to delete the Go directory located at “/usr.local” path:

$ sudo rm -rf /usr/local/go

This removes Go from your Raspberry Pi system.

Conclusion

Go is a robust programming language helpful in developing different scalable applications. You can install this language on your Raspberry Pi system from two methods. The first method is installing it from the Raspberry Pi repository through the “apt” installation command. Though the method is easy, it won’t install the latest Go version on your system. The second method, through a tar.gz file, successfully installs the latest Go version on your Raspberry Pi system.

About the author

Awais Khan

I'm an Engineer and an academic researcher by profession. My interest for Raspberry Pi, embedded systems and blogging has brought me here to share my knowledge with others.