Skip to content
Related Articles

Related Articles

Improve Article

How to Install Go Programming Language in Linux

  • Last Updated : 17 Jun, 2021

In this article, we will discuss how to install GoLang (Go Programming Language) in Linux. But at first let’s know a brief about GoLang.

GoLang is a procedural programming language. It was developed in 2007 by Robert Griesemer, Rob Pike, and Ken Thompson at Google but launched in 2009 as an open-source programming language. Programs are assembled using packages, for efficient management of dependencies. This language also supports the environment adopting patterns alike to dynamic languages.

Download Go Latest Stable Version

Download GoLang using this link and choose the latest version of GoLang in an archive and install using the below command:

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

Download GoLang using the wget command

Verify the downloaded tarball version by verifying the SHA256 checksum of the downloaded file using the command below :



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

Extract the ‘go1.16.5.linux-amd64.tar.gz’ Go tarball file to the ‘/usr/local’ directory next.

$ sudo tar -C /usr/local -xzf go1.16.5.linux-amd64.tar.gz

In the /usr/local directory, you’ll find a directory called go. Change the owner and group of this directory to root recursively:

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

Configure System Environment for Go

To construct the directory structure for your Go workspace, run the following command:

$ mkdir -p $HOME/go/{bin,src}

By adding global variables to your /.profile, you can set your $GOPATH. To begin, open /.profile in nano or another text editor:



$ nano ~/.profile

Now Append the following lines then save and close:

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

To load the global variables, run the following command to update your shell:

$ . ~/.profile

Using the echo command and analyzing the result, you can check that your $PATH has been updated:

$ echo $PATH

Verify the installation by looking at the current Go version:

$ go version

Verify GoLang Installation

Write a simple Go Hello World program to see if your Go installation is operating properly. Create a new file called hello.go then save and close:

$ nano hello.go

Now compile and run the go program:

$ go run hello.go

My Personal Notes arrow_drop_up
Recommended Articles
Page :