How To Install Go (Golang) on Linux Mint 20/19

Posted on 353 views

Question: How to install Go on Linux Mint 20/19?, How to install Golang on Linux Mint20/19?. In today’s guide, we will see how you can easily install Go/Golang on Linux Mint20/19. Go is a popular open-source programming language designed for concurrency and is widely known for its efficiency, clean design, expressive, and concise design model.

You have three options of installing Go on Linux Mint 20/19

  1. Install Go on Linux Mint 20/19 from APT repository
  2. Install Go on Linux Mint 20/19 from Snap
  3. Install Go on Linux Mint 20/19 using Golang installer

For Ubuntu refer to: How to Install latest Go on Ubuntu

For RHEL 8 / CentOS 8: How to Install Go on RHEL 8

Method 1: Install Go on Linux Mint 20/19 from APT repository

This is the easiest method of installing Go on Linux Mint 20/19. Simply add the PPA repository by running the command below in your terminal.

sudo add-apt-repository ppa:longsleep/golang-backports

Press Enter key when prompted to add the repository and import GPG key required for packages verification.

Once the PPA repository has been added, update your package list index and install Go.

sudo apt-get update
sudo apt-get install golang-go

You can confirm installed version using the go version option.

$ go version
go version go1.17.2 linux/amd64

Method 2. Install Go on Linux Mint 20/19 from Snap

To use snap, you need to have installedsnapd which will provides snap command used to install Go on Linux Mint20/19.

sudo apt-get update
sudo apt-get install snapd

Then install Go on Linux Mint20/19.

sudo snap install --classic go

You should see a message like below at the end.

go 1.17.2 from Michael Hudson-Doyle (mwhudson) installed

Method 3: Install Go on Linux Mint20/19 using Golang installer

The last method you can consider is using official Golang installer for Linux systems.

Download it with wget to your local system.


After downloading the file, make it executable:

chmod +x ./installer_linux

And lastly run the installer from your current terminal shell.

$ ./installer_linux 
Welcome to the Go installer!
Downloading Go version go1.17.3 to /home/ubuntu/.go
This may take a bit of time…
Setting up GOPATH
GOPATH has been set up!

One more thing! Run source /home/jmutai/.bash_profile to persist the new environment variables to your current session, or open a new shell prompt.

Source the ~/.bash_profile to start using Go environment variables in your current session.

$ source ~/.bash_profile
$ go version
 go version go1.17.3 linux/amd64

Your Go PATH when using this method is ~/.go

Set Go PATH – For Method 1&2

Run the commands below to set your set $GOPATH

mkdir -p ~/go/bin,pkg,src
echo 'export GOPATH="$HOME/go"' >> ~/.bashrc
echo 'export PATH="$PATH:$GOPATH//://bin:/bin"' >> ~/.bashrc

Testing your Go environment

Let’s create a simple hello Go program to test our installation of Go on Linux Mint20/19.

mkdir -p ~/go/src/test
vim ~/go/src/test/test.go

Add print Hello Gophers message

package main
import "fmt"
func main() 
    fmt.Printf("Hello, Gophers\n")

Build test.go file

cd ~/go/src/test
go build

Run binary to test

$ ./test
Hello, Gophers

To install the binary into your workspace’s bin directory, use:

$ go install
$ ls ~/go/bin/

To remove it use:

go clean -i

Enjoy your Development with Go Linux Mint20/19.

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.