Install Go Lang on Ubuntu

In this quick tutorial we'll see how to install Go Lang version 1.19 on Ubuntu!
I keep these installation tutorials simple and straightforward because I know how frustrating it is to read through an entire article when you are simply looking for terminal commands. So if this article looks bland, it is very much on purpose :)
Intall Go Lang
Install Ubuntu updates
sudo apt-get update
sudo apt-get -y upgrade
Download Go binary
mkdir temp
cd temp
wget https://dl.google.com/go/go1.19.linux-amd64.tar.gz
Extract the downloaded tar and install it into the desired location in the system.
sudo tar -xvf go1.19.linux-amd64.tar.gz
sudo mv go /usr/local
Environment setup
The Go language environment variables we need are GOROOT , GOPATH and PATH.
- Export directly from the terminal; keep in mind that using this method, you'll need to declare them again every time you restart the terminal.
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
- Place the environment variables in the
.bashrcfile. This way, you don't need to declare them every time you restart the terminal.
Open the .bashrc file.
/bin/nano ~/.bashrc
Add the environment variables at the end of the file.
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH
Close and save the file.
Ctrl + x
y
enter
Source the .bashrc file.
source ~/.bashrc
Now verify that go was installed correctly with the `go version`` command.
go version
Should return something similar to the following.
go version go1.19 linux/amd64





