Install Go (Golang) on Ubuntu 26.04 and Debian 13 (2 Methods)

You must have heard about Go (also known as Golang). Go is a simple, open-source programming language created by Google. It is widely used for web applications (APIs and microservices), cloud-native applications (Docker and Kubernetes), DevOps and CLI tools and much more. Since it is fast (it compiles quickly), has a simple syntax, and includes a robust standard library, Go is an excellent choice for new programmers starting their careers in the IT industry. Even if you are a professional and looking for the best setup, you can follow this tutorial. If you are a programmer, then you can also try Rust. I have published a tutorial to install Rust on Ubuntu 26.04 and Debian 13 trixie.

In this tutorial, i will tell you how to install Go (Golang) on Ubuntu 26.04 and Debian 13 Trixie. You can follow any of the two methods to install Go. So, let’s begin.

Prerequisites

  • A VM or PC running Ubuntu 26.04 or Debian 13
  • A user with sudo privileges

Update the Server

Before will begin the installation, let’s first update the system

sudo apt update -y
sudo apt upgrade -y

Method 1 – Install Go (Golang) using Package Manager

The first method installs Go from the Ubuntu and Debian repositories using APT. This is the most simple and reliable method because you manage everything via the package manager.

Just execute the command below and it will install Go on your system

sudo apt install golang-go

You can check if it is installed by

go version

and the output you can see is

go version go1.xx.x linux/amd64

Method 2 – Download and Install from Official Go Release

The second method to install Go is from the official Go release. This method is recommended if you want the latest stable version of Go instead of the version available in the Ubuntu/Debian repositories.

Step 1 – Remove Previous Go Installation (If Any)

Let’s first delete any previous version if available

sudo rm -rf /usr/local/go

Step 2 – Download Go (Golang) from Official Website

Now, open any browser and copy the latest download link from the official Go website and paste it along with the wget command as shown below. If you’re using an ARM64 system, download the ARM64 archive from the Go downloads page instead.

wget https://go.dev/dl/go1.26.5.linux-amd64.tar.gz

Step 3 – Unzip the Package

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

Go has been extracted to /usr/local/go. Now add its bin directory to your PATH so you can run the go command from anywhere.

echo 'export PATH=$PATH:/usr/local/go/bin:~/go/bin' >> ~/.bashrc
source ~/.bashrc

Step 4 – Verify the Installation

Let’s verify if the installation is correct

go version

If everything is correct, you should see the version number of Go

Create First Program

As the installation is done, let’s create a test program

First create a new file

nano hello.go

Paste this in the file

package main

import "fmt"

func main() {
    fmt.Println("Hello, Nice to meet you!")
}

Save the file with “ctrl+x“, y and press Enter

Now let’s run the program

go fmt hello.go
go run hello.go

You should see an output as

Hello, Nice to meet you!

With this, Golang is installed on your system and working perfectly fine.

Some Important Administrative Commands

To Check Environment

To check the details like installation path, Operating System, etc, you can use the below command

go env

To Update Go (Golang)

In future, when you want to update Go (Golang), just follow the steps below

If installed using Method 1

sudo apt update -y
sudo apt upgrade -y

If installed using Method 2

  • Download the latest tarball.
  • Remove /usr/local/go.
  • Extract the new archive.
  • Verify with go version.

To Uninstall Go (Golang)

Any time when you want to uninstall Go from your system, you just have to remove the directory

If installed using Method 1

sudo apt remove golang-go -y
sudo apt autoremove -y

If installed using Method 2

sudo rm -rf /usr/local/go

Conclusion

With this, Go (Golang) has been installed on your Ubuntu 26.04 and Debian 13 VM or PC.

Leave a Comment

Sourabh Verma

Hi, I'm Sourabh Verma, an IT professional with 12+ years of experience. At BeginnersBox, I share practical, well-tested how-to guides on Windows, Linux, WordPress, web hosting, and other tech topics. My goal is to provide simple, reliable solutions that actually work. Hope you like my work. Thanks

Discover more from BeginnersBox

Subscribe now to keep reading and get access to the full archive.

Continue reading