Go (also called Golang) is an open-source programming language built by Google. It is designed to be fast, simple, and efficient — especially for networked services, command-line tools, and cloud infrastructure.
Many widely used tools are built in Go:
Go is a compiled language. You write source code, compile it into a binary, and run that binary. The final executable does not need the Go runtime on the target machine, which makes Go programs easy to deploy. It also has built-in concurrency support, which makes it well-suited for services that handle many requests at the same time.
This guide shows you how to install Go on Ubuntu 20.04 and run your first Go program.
<strong>Prerequisite:</strong> You need sudo access to follow these steps.
Before running the command below, visit the official Go downloads page and check for the latest stable version. This example uses Go 1.14.2. Replace the version number in the URL if a newer release is available.
Download and extract Go into /usr/local:
bashwget -c https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local
This places the Go tools in /usr/local/go. The main binary is at /usr/local/go/bin/go. If you want to manage multiple Go versions on the same machine, look into a version manager like gvm.
You need to tell the system where to find the Go binary. Add this line to your ~/.profile file for a single-user setup:
bashexport PATH=$PATH:/usr/local/go/bin
For a system-wide setup that applies to all users, add the same line to /etc/profile instead.
Load the new PATH into your current shell session:
bashsource ~/.profile
You only need to run source once. On future logins, the PATH loads automatically.
Confirm Go is installed and the PATH is working:
bashgo version
The output should show the version you installed:
go version go1.14.2 linux/amd64
A quick way to test your setup is to build and run a small Hello World program.
Create a workspace and project directory:
bashmkdir -p ~/go/src/hello
Inside that directory, create a file called hello.go with this content:
gopackage mainimport "fmt"func main() { fmt.Printf("Hello, World\n")} Navigate into the project directory and build it:
bashcd ~/go/src/hellogo build
This creates an executable called hello. Run it:
bash./hello
Output:
Hello, World
Go compiled your source code into a native binary. That binary runs without needing Go installed on the machine. Unlike Python or JavaScript, you can ship a single file and it works anywhere with the same OS and architecture.
<strong>Tip:</strong> For modern Go projects, use Go modules instead of the GOPATH workspace. Run <code>go mod init your-module-name</code> in any project directory to get started.
Go is now installed on your Ubuntu system. You have everything you need to start writing and compiling Go programs. Check out the official Go documentation for language tours, standard library references, and project guides. Got questions? Leave a comment below.
MySQL is the most popular open-source relational database management system. It is fast, reliable, and a…
Git is the most widely used version control system in the world. It was created by…
Visual Studio Code (VS Code) is an open-source code editor developed by Microsoft. It is one…
Nginx (pronounced "engine x") is an open-source, high-performance web server and reverse proxy. It is used…
Apache is one of the most widely used open-source web servers in the world. It is…
Swap space is an area on disk that Linux uses when it runs out of physical…