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
- Install Go on Linux Mint 20/19 from APT repository
- Install Go on Linux Mint 20/19 from Snap
- 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
$ 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 installed
snapd 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… Downloaded! 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.
~/.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
Set Go PATH – For Method 1&2
Run the commands below to set your set
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")
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/ test
To remove it use:
go clean -i
Enjoy your Development with Go Linux Mint20/19.