sammlinux sammlinux
  • Ubuntu
    UbuntuShow More
    How To Install and Use Docker CE on Ubuntu 22.04
    26 Min Read
    How To Install and Secure phpMyAdmin on Ubuntu 22.04
    5 Min Read
    How To Secure SSH with Fail2Ban on Ubuntu 22.04
    8 Min Read
    How To Install Uptime Kuma on Ubuntu 22.04
    17 Min Read
    How To Install Ubuntu Server 22.04 LTS with Screenshots
    14 Min Read
  • Rocky Linux
    Rocky LinuxShow More
    How To Install phpMyAdmin on Rocky Linux 9
    15 Min Read
    How To Secure SSH with Fail2Ban on Rocky Linux 9
    12 Min Read
    How To Install Rocky Linux 9.2 Server with Screenshots
    12 Min Read
    How To Set Up a Firewall Using FirewallD on Rocky Linux 9
    8 Min Read
    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide
    10 Min Read
  • Debian
    DebianShow More
    How To Secure SSH with Fail2Ban on Debian 11
    8 Min Read
    How To Install Debian 11 (Bullseye) Server with Pictures
    12 Min Read
    How To Install and Setup Node.js on Debian 11
    6 Min Read
    How To Install PHP 8.2 on Debian 11
    12 Min Read
    How To Install Nginx on Debian 11: A Comprehensive Guide
    9 Min Read
  • Linux
    LinuxShow More
    Best Practices Linux Server Security for System Administrator
    8 Min Read
    A Simple Guide: How To Manage Groups on Linux
    5 Min Read
    How To Manage Log Files Using Logrotate In Linux
    7 Min Read
    The Easy Ways to Check File Size in Linux
    7 Min Read
    How To Backup Files From Remote Linux VPS Using Rsync Script
    12 Min Read
  • CentOS
    CentOSShow More
    How To Secure SSH with Fail2Ban on CentOS 7
    9 Min Read
    How To Install PHP 8.2 on CentOS 7 / RHEL 7
    18 Min Read
    How To Install Apache Web Server on CentOS 7
    11 Min Read
    How To Set Up a Firewall Using FirewallD on CentOS 7
    5 Min Read
    Initial Setup CentOS 7 Server: Secure and Efficient
    9 Min Read
  • DevOps
    DevOpsShow More
    How To Create AWS CloudFront: A Step-by-Step Guide
    10 Min Read
Reading: How To Install and Configure Go (Golang) on Ubuntu 22.04
Share
Font ResizerAa
Linux for BeginnersLinux for Beginners
  • Ubuntu
  • Rocky Linux
  • Debian
  • Linux
  • CentOS
  • DevOps
Search
  • Ubuntu
  • Rocky Linux
  • Debian
  • Linux
  • CentOS
  • DevOps
Follow US
Copyright © 2014-2023 Ruby Theme Ltd. All Rights Reserved.

How To Install and Configure Go (Golang) on Ubuntu 22.04

Samuel Siahaan
By Samuel Siahaan
Last updated: April 5, 2023
SHARE

Introduction

In the world of programming, efficiency and performance are key factors that can greatly impact the success of any project. One programming language that has gained immense popularity for its speed and efficiency is Go, also known as Golang. Developed by Google, Go is designed to provide developers with a reliable and robust platform for building efficient and scalable software. In this article, we will walk you through a step-by-step guide on how to install and configure Go on Ubuntu 22.04 to ensure optimal performance.

Contents
IntroductionTable of ContentsPrerequisitesInstalling Go on Ubuntu 22.04Method 1: Using Apt CommandStep 1: System UpdateStep 2: Install Go on Ubuntu 22.04Method 2: Install Go from Binary FileStep 1: Download GoStep 2: Add the Golang binary to the $PATHHow to use Go in Ubuntu 22.04Conclusion

Table of Contents

  • Introduction
  • Prerequisites
  • Installing Go on Ubuntu 22.04
  • Method 1: Using Apt Command
    • Step 1: System Update
    • Step 2: Install Go on Ubuntu 22.04
  • Method 2: Install Go from Binary File
    • Step 1: Download Go
    • Step 2: Add the Golang binary to the $PATH
  • How to use Go in Ubuntu 22.04
  • Conclusion

Go is commonly used for various purposes, such as web development, networking applications, system programming, cloud services, and containerization (e.g., Docker). Its popularity in the software industry continues to grow due to its performance, simplicity, and strong concurrency support, making it an attractive choice for modern application development.

Prerequisites

  • Ubuntu 22.04. Before you begin, you should have a non-root user account with sudo privileges set up on your system. You can learn how to do this by following the Initial Server Setup Guide with Ubuntu 22.04 tutorial.
  • It would help if you used a fresh OS install to prevent potential issues.

Installing Go on Ubuntu 22.04

Go is a programming language developed by Google. It’s an open-source, statically typed, compiled language which provides garbage collection, memory safety, and concurrency.

There are several methods to install Go on Ubuntu 22.04 and the details of each method are given below:

- Advertisement -

This tutorial explains how to install Go on Ubuntu 22.04.

Method 1: Using Apt Command

The apt package management system in Ubuntu 22.04 includes the repository of Go, thus allowing the user to install the latest version of software directly from the apt command. You can use the following installation command to install Go on Ubuntu:

Step 1: System Update

Before we begin, it’s essential to ensure that your system packages are up to date. Open a terminal and run the following commands:

samm@go:~$ sudo apt-get update -y 

Running the update command will inform you of the number of packages that need to be upgraded. However, you can choose to skip this step if there are no packages to upgrade.

samm@go:~$ sudo apt-get upgrade -y

Step 2: Install Go on Ubuntu 22.04

If you are curious enough, you can search for the availability of the golang-go package from Debian / Ubuntu repositories as shown.

- Advertisement -
samm@go:~$ apt search golang-go

Output :

Sorting... Done
Full Text Search... Done
gccgo-go/jammy 2:1.18~0ubuntu2 amd64
  Go programming language -- gccgo

gogoprotobuf/jammy 1.3.2-1 amd64
  alternative protocol buffer support for Golang - utilities

golang-1.17/jammy-updates 1.17.13-3ubuntu1 all
  Go programming language compiler - metapackage

golang-1.17-go/jammy-updates 1.17.13-3ubuntu1 amd64
  Go programming language compiler, linker, compiled stdlib

golang-1.18/jammy-updates,jammy-security 1.18.1-1ubuntu1.1 all
  Go programming language compiler - metapackage

golang-1.18-go/jammy-updates,jammy-security 1.18.1-1ubuntu1.1 amd64
  Go programming language compiler, linker, compiled stdlib

golang-1.20/jammy-updates 1.20.3-1ubuntu0.1~22.04 all
  Go programming language compiler - metapackage

golang-1.20-go/jammy-updates 1.20.3-1ubuntu0.1~22.04 amd64
  Go programming language compiler, linker, compiled stdlib
......

To install Golang Go using apt command, run

samm@go:~$ sudo apt install golang-go

Output :

- Advertisement -
samm@go:~$ sudo apt install golang-go
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
The following additional packages will be installed:
golang-1.18-go golang-1.18-src golang-src pkg-config
Suggested packages:
bzr | brz mercurial subversion
The following NEW packages will be installed:
golang-1.18-go golang-1.18-src golang-go golang-src pkg-config
0 upgraded, 5 newly installed, 0 to remove and 11 not upgraded.
Need to get 82.4 MB of archives.
After this operation, 437 MB of additional disk space will be used.
Do you want to continue? [Y/n]

Press “Y“ to continue installation.

Once the installation is complete, verify that Go is installed as shown.

samm@go:~$ go version
go version go1.18.1 linux/amd64

From the output, you can see that Go version 1.18.1 has been installed. Notably, this is not the latest version at the time of writing this guide.

Method 2: Install Go from Binary File

You can use this method to install the latest version of Go on Ubuntu 22.04. For that purpose, you will need to follow the steps given below:

Step 1: Download Go

Start by visiting the official download page Go to download the latest stable version of Go and download the 64-bit tarball installation file (amd64.tar.gz)

On the command line, you can download the latest tarball file using the wget command. At the time of writing this guide, the latest version of Go is Go 1.20.7. This is likely to change by the time you are reading this guide, so ensure to replace the version number accordingly.

samm@go:~$ curl -o go.tar.gz "https://dl.google.com/go/$(curl https://go.dev/VERSION?m=text).linux-amd64.tar.gz"

Once the download is complete, extract the tar.gz file to the /usr/local directory:

samm@go:~$ sudo tar xf go.tar.gz -C /usr/local

Step 2: Add the Golang binary to the $PATH

The next step is to specify where Go binaries are located. Add the /usr/local/go/bin directory to the system’s PATH environment variable. It can be set in /etc/profile file. In this case, Go will be available for all users as a system-wide command. To achieve this, run the following command:

samm@go:~$ vi ~/.bashrc

Paste the following line.

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

Save the changes and exit the file.

Next, to make changes to take effect, reload the .bashrc or .bash_profile file using the source command as shown.

samm@go:~$ source ~/.bashrc

To ensure the installation was successful, we will check the version of “Go.”
To do this, execute the “go” command together with the “version” option on the terminal as shown below:

samm@go:~$ go version
go version go1.20.7 linux/amd6

The following output shows that go has successfully been installed.

How to use Go in Ubuntu 22.04

After completing the Go installation, proceed to execute a simple code written in the Go language. This test will determine whether the environment is functioning correctly on Ubuntu.

We will create a separate directory for our project as follows.

samm@go:~$ mkdir go-project

Now go to the directory and run the example module using the following commands:

samm@go:~$ cd go-project/

We will create a simple program called hai.go that prints out a simple message on the terminal.

samm@go:~/go-project$ vi hai.go

Copy and paste the following lines of code into the file.

package main
import "fmt"
func main() {
    fmt.Printf("Congratulations samm!! Go has successfully been installed on your systemn")
}

Save the changes and exit. Then run the program as follows

samm@go:~/go-project$ go run hai.go

You will get the following output. This confirms that the installation of Golang Go is working as expected.

Congratulations samm!! Go has successfully been installed on your system
Install Go on Ubuntu
Sample Project Go

That’s it, now you can execute other codes using the same method on Ubuntu 22.04. For further guidance, you can read the Go Documentation.

Conclusion

Congratulations! You have successfully installed and configured Go on your Ubuntu 22.04 system. Go’s performance-oriented design and simplicity make it a powerful tool for developing efficient applications. By following the steps outlined in this guide, you’ve set up a solid foundation for building high-performance software using the Go programming language. Start exploring Go’s extensive libraries and tools to unlock its full potential in your projects. Happy coding!

Also Read Our Other Guides :

  • How To Install and Configure Elasticsearch on Ubuntu Server 22.04
  • How To Install and Configure NFS Server Client on Ubuntu 22.
  • How To Install Jenkins on Ubuntu 22.04
  • How To Install a MinIO Object Storage Server on Rocky Linux

Finally, now you have learned how to install and configure Go (Golang) on Ubuntu 22.04.

TAGGED:GoGolangLinuxProgramming LanguageUbuntu

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
[mc4wp_form]
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article How To Install VirtualBox 7.0 on Ubuntu 22.04
Next Article How To Install Composer in Ubuntu 22.04: A Comprehensive Guide
Leave a Comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

How To Install and Secure phpMyAdmin on Ubuntu 22.04
Ubuntu
Install and Configure Docker Swarm Mode on Centos 7
CentOS
How To Install and Config Thumbor on Debian 10
Debian
How To Install MariaDB 10.6 on Debian 11 Server
Debian
How To Install MongoDB 6.0 on Debian 10 & 11
Debian

You Might Also Like

Ubuntu

How To Install and Configure NFS Server Client on Ubuntu 22.04

16 Min Read
Linux

The Easy Ways to Check File Size in Linux

7 Min Read
Ubuntu

How To Install Apache 2.4 on Ubuntu 22.04

10 Min Read
Linux

How To Use Rsync to Sync Local and Remote Directories in Linux

8 Min Read
Linux

How To Install and Use Linux Screen with Commands

9 Min Read
Ubuntu

How To Install Node.js on Ubuntu 22.04 With 3 Different Ways

20 Min Read
Ubuntu

How To Build NGINX from Source (Compile) on Ubuntu Server 22.04

13 Min Read
Linux

6 Methods To Search For Files By Name In Linux

7 Min Read
Show More

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!

sammlinux sammlinux

Providing beginner-friendly Linux tutorials and open-source guides to simplify your digital infrastructure.

www.sammlinux.com © 2026 | All Rights Reserved

Join Us!
Subscribe to our newsletter and never miss our latest news, podcasts etc.

Subscribe to our newsletter to get our newest articles instantly!

Zero spam, Unsubscribe at any time.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?