Install Go on Ubuntu 20.04 - Step by step process to do it ?

Go is a programming language that is created by Google. It’s an open-source language, its syntax is similar to C but it has some advantages over C such as concurrency processing, full support for multiple-cores CPU, garbage collection.

Go is a compiled programming language, you have to compile the source code to create an executable running file.

Almost all famous Cloud Native projects are written in Go: Kubernetes, Docker, Etcd, CoreDNS, and so on.

Go is cross-platform, it can be installed on Linux, Windows, and macOS.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform Ubuntu related queries.

In this context, we shall look into how to install Go on your Ubuntu 20.04 machine.

Main Features of Go Programming

Below are some of the core features of Go:

1. Statically type and compiled programming language.

2. Concurrency support and Garbage collection.

3. Strong library and toolset.

4. Multiprocessing and High-performance networking.

5. Known for readability and usability (Like Python).

How to install Go on Ubuntu ?

To start this installation process, we need to follow the steps given below.

1. Download the Go package.

At the time of this writing, the latest stable Go version is 1.15.7. You can visit the official Golang download page at https://golang.org/dl/.

To download the Go tarball, run the following command:

$ wget https://golang.org/dl/go1.15.7.linux-amd64.tar.gz
$ sudo tar xf go1.15.7.linux-amd64.tar.gz -C /usr/local

2. Modify the Path environment variable

You have to add the extracted Go directory in the previous step to the $PATH variable so that the OS can know where the Go executable binaries are located.

Using your favorite editor to insert the following line to $HOME/.profile file or /etc/profile file:

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

Then, re-load the new PATH environment variable by running:

$ source .profile

Verify that Go is successfully installed on your system:

$ go version

3. Working with Go

Here, We're going to build a simple Go program for demonstration.

i. To begin, create a workspace directory for Go by running:

$ mkdir ~/go

ii. Then, create a sub-directory src/hello-world in ~/go

$ mkdir -p ~/go/src/hello-world

In the ~/go/src/hello-world directory, let's use your favorite editor to create a Go source file named helloworld.go. Its content as below:

package main
import "fmt"
func main() {
fmt.Println("Hello, Linuxapt.com")

iii. To build the program, running the command:

$ go build

iv. Execute the program:


How to uninstall Go Language from Ubuntu?

To remove Go from the system remove the directory where the go tarball is extracted. 

In this case, go is extracted to /usr/local/go. 

Also, remove the entry from ~/.bashrc or ~/.bash_profile depending upon where you added the export path.

To implement this, run the commands given below:

$ sudo rm -rf /usr/local/go
$ sudo nano ~/.bashrc        # remove the entry from $PATH
$ source ~/.bashrc

[Need urgent assistance in fixing missing packages on Ubuntu Linux Server? We are available to help you today. ]


This article covers how to install Go on your Ubuntu 20.04 machine. Now you can start programming Go language. Go is a popular programming language created by Google. 

Many modern applications such as Docker, Kubernetes, and Caddy are written in Go.

To install Go on Ubuntu:

1. Use curl or wget to download the current binary for Go from the official download page. As of this writing, the current version is 1.12.9. 

Check the download page for updates, and replace 1.12.9 with the most recent stable version if necessary:

$ curl -O https://storage.googleapis.com/golang/go1.12.9.linux-amd64.tar.gz

Verify the .tar file using sha256sum:

$ sha256sum go1.12.9.linux-amd64.tar.gz

3. Extract the tarball:

$ tar -xvf go1.12.9.linux-amd64.tar.gz

4. Adjust the permissions and move the go directory to /usr/local:

$ sudo chown -R root:root ./go
$ sudo mv go /usr/local