Skip to main content

Command Palette

Search for a command to run...

Install Go Lang on Ubuntu

Published
2 min read
Install Go Lang on Ubuntu
D

Hey there! I'm Davide, a passionate developer advocate at Chainstack, the leading suite of blockchain infrastructure services.

I'm dedicated to empowering current and aspiring web3 developers by sharing valuable content and resources.

Within my articles, you'll discover a treasure trove of straightforward projects designed to bolster your understanding of fundamental Python, Solidity, JavaScript, and web3 skills. Whether you're a seasoned developer or just starting out, these projects offer an ideal learning path for honing your abilities in the exciting world of blockchain development.

Feel free to explore my articles, and let's embark on this remarkable journey of mastering web3 together!

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.

  1. 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
  1. Place the environment variables in the .bashrc file. 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