How to Install Golang in Ubuntu 20.0.4

12/25/2020Golanggolang,ubunt

There are two ways to install Golang in Ubuntu. But to install the latest one, I highly recommend to download the binary file from the official go website.


Download Golang binary file

$ sudo wget https://golang.org/dl/go1.15.6.linux-amd64.tar.gz

Extract the files from the downloaded tar file.

$ sudo tar xvzf go1.15.6.linux-amd64.tar.gz

as the result, go directory is created.

Move go directory to /usr/local

$ mv go /usr/local/

Add Go binary path to the PATH environment variable.

Here, as an example, add the path to the .profile file.

$ vi .profile

Add the following line.

#Path of GO products
export GOROOT=/usr/local/go
#Top directory of your go environment that will include your projects in the future
export GOPATH=/share/go
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

Then reload the .profile file to apply changes.

$ . .profile

Verify the setting

Execute the following go command to check if installation is ok or not.

$ go version
go version go1.15.6 linux/amd64

If the version is shown properly, your installation is commpleted without problem!