Home  »  ArticlesGuidesHow ToProgrammingSoftwareTechnologyTools   »   A Comprehensive Guide to Installing Go (Golang) on Ubuntu 24.04, 22.04, and 20.04 Linux Systems

A Comprehensive Guide to Installing Go (Golang) on Ubuntu 24.04, 22.04, and 20.04 Linux Systems

Go, also known as Golang, is a powerful, efficient, and statically typed programming language developed by Google. It’s well-suited for building reliable and efficient software. Whether you’re developing web applications, microservices, or system tools, Go’s simplicity and performance make it a popular choice. This guide will walk you through the steps to install Go on Ubuntu 24.04, 22.04, and 20.04 systems.

Why Choose Go?

Go is designed for simplicity, concurrency, and performance. It compiles to machine code, has garbage collection, and provides robust concurrency mechanisms. These features make it an excellent choice for developers looking for a balance between speed and ease of use.


Before starting the installation, ensure you have the following:

  1. A system running Ubuntu 24.04, 22.04, or 20.04.
  2. Sudo privileges: Administrative access to install new software packages.

Step-by-Step Installation Guide

Step 1: Download the Go Binary

First, download the latest Go binary from the official Go website. You can use wget to download the file directly to your system. As of this writing, the latest stable version is 1.20. If there is a newer version, replace the version number in the URL.

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

Step 2: Verify the Download (Optional)

To ensure the integrity of the downloaded file, you can verify it using the SHA256 checksum. First, download the checksum file from the Go website, then use the sha256sum command:

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

Compare the output with the checksum provided on the Go download page.

Step 3: Extract the Archive

Next, extract the tarball to the /usr/local directory. This is the recommended location for Go installations:

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

Step 4: Set Up the Go Environment

To make Go available system-wide, you need to add the Go binary to your PATH. You can do this by editing your shell profile file. For Bash, this file is typically .bashrc or .profile. For Zsh, it’s .zshrc.

Open the profile file with your preferred text editor:

$ nano ~/.bashrc

Add the following lines to the end of the file:

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

Save and close the file, then reload the profile to apply the changes:

$ source ~/.bashrc

Step 5: Verify the Installation

Verify that Go is installed correctly by checking the version:

$ go version

You should see output similar to:

$ go version go1.20 linux/amd64

Step 6: Set Up Your Go Workspace

Go encourages a specific workspace structure. By default, Go looks for its workspace under ~/go. You can set this up by creating the necessary directories:

$ mkdir -p ~/go/{bin,src,pkg}

Add the workspace directory to your GOPATH. Again, open your profile file:

$ nano ~/.bashrc

Add the following line:

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

Save and close the file, then reload the profile:

$ source ~/.bashrc


Congratulations! You have successfully installed Go (Golang) on your Ubuntu 24.04, 22.04, or 20.04 system. You are now ready to start developing applications using Go’s powerful and efficient features. Happy coding!

Feel free to explore Go’s rich set of libraries and tools, and check out the official documentation for more in-depth guides and tutorials.

Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.