In this guide, I’ll walk you through different ways you can install Go on Ubuntu 20.04/18.04 & CentOS 7 server. Go is an open source programming language with a novel type system to enable flexible and modular program construction, and make programmers more productive.

Go uses concurrency mechanisms which makes it easy to write programs that get the most out of multicore and networked machines. Go has been known to be efficient, clean, expressive and concise.

It is a fast, statically typed, compiled language that feels like a dynamically typed, interpreted language.

Linux Mint 19: How to Install Go (Golang) on Linux Mint 19

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

Installing Go (Golang) on CentOS 7

We have two options to install latest Go on CentOS 7

Method 1: Using Go repository ( For CentOS 7 only)

We will use a Go repository to ensure we are getting the latest release without having to build it.

sudo rpm --import
curl -s | sudo tee /etc/yum.repos.d/go-repo.repo

Once the repository has been added, install golang package

sudo yum install golang

Go binary will be placed under /bin/go

$ which go

Install Go on Ubuntu 18.04

For Ubuntu 18.04 server, add Golang backports PPA repository and install Go on Ubuntu 18.04.

sudo add-apt-repository ppa:longsleep/golang-backports 
sudo apt-get update
sudo apt-get install golang-go


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

Method 2: Install Go using Golang installer

The second method is the installation of Go from provided Golang installer.

First install wget

sudo apt-get -y install wget
sudo yum -y install wget

Download installer 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.11.5 to /home/jmutai/.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.11.5 linux/amd64

Method 3: Manually Download Go

The second method involves downloading Go archive and installing it to the system. You may need to check Go releases page for the latest version.

Ensure you have wget installed

sudo yum install wget
sudo apt install wget

Then download Go

sudo tar -C /usr/local -xzf go${VER}.linux-amd64.tar.gz
rm go${VER}.linux-amd64.tar.gz

Set Go PATH Variable

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 Go installation on Ubuntu 18.04 / CentOS 7

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

Thanks for using our guide to install latest Go on CentOS 7 and Ubuntu 20.04/18.04 server.

Learning Video courses:


  • How to Install Golang on Ubuntu 20.04/18.04
  • How to Install Golang on CentOS 7
  • How to Install latest Golang on Ubuntu 20.04/18.04
  • How to Install latest Golang on CentOS 7
  • How to Install latest Go on Ubuntu 20.04/18.04
  • How to Install latest Go on CentOS 7

Your support is our everlasting motivation,
that cup of coffee is what keeps us going!

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.


Please enter your comment!
Please enter your name here