How to Install Go on Debian

October 21, 2022

Introduction

Go, or Golang, is a relatively new, open-source language created by Google. The purpose of Go is to streamline software development, enabling users to create simple and reliable apps. 

As a modern language, Go offers memory allocation, concurrency support, garbage collection, coordination avoidance, etc.

In this article, you will learn how to install Go on Debian in a few simple steps.

How to Install Go on Debian

Prerequisites

  • Debian system (This tutorial uses Debian 11).
  • A non-root sudo user.
  • Access to the command line.

How to Install Go on Debian 11?

Before starting the installation, ensure the Debian server is up to date. Update the repository and upgrade packages with the following:

sudo apt update && sudo apt -y
sudo apt update and sudo apt upgrade -y terminal output

Step 1: Download Go

To start the installation process:

1. Visit the Go downloads page.

2. Click the Linux box under Featured downloads to start the download.

Pick Linux download

3. Save the file in case the download does not start automatically.

Note: Use wget or curl to download Go without accessing the browser.

Step 2: Extract Files

Extract files to the /usr/local directory. To accomplish that, navigate to Downloads via the terminal and run:

sudo tar -C /usr/local -xzf go1.19.2.linux-amd64.tar.gz
sudo tar command terminal output

The command doesn't print any output. However, tar extracts the specified file (go1.19.2.linux-amd64.tar.gz) to the desired directory.

Step 3: Set the Environment

To set the environment variable, add /usr/local/go/bin to PATH.

Take the following steps:

1. Access .profile in Vim or another text editor.

2. At the end of the file, paste the following line:

export PATH=$PATH:/usr/local/go/bin
Add to PATH in Vi

3. Save and close the file.

Note: To install Go system-wide, edit /etc/profile. To install it for the current user, access $HOME/.profile.

Step 4: Verify the Installation

To confirm Go is installed on the machine, run go version:

Checking Go version terminal output

The output shows that the system includes a go1.19.2 version of Go, confirming a successful installation.

Conclusion

This tutorial explains how to install Go on Debian and how to verify the instsallation.

Next, read about the best Linux text editors for coding.

Was this article helpful?
YesNo
Sara Zivanov
Sara Zivanov is a technical writer at phoenixNAP who is passionate about making high-tech concepts accessible to everyone. Her experience as a content writer and her background in Engineering and Project Management allows her to streamline complex processes and make them user-friendly through her content.
Next you should read
How to Install Node.js on Debian
October 6, 2022

Node.js is an open-source JavaScript runtime used for creating fast and scalable network applications. This guide will show you how to install Node.js on Debian...
Read more
Fail2Ban Installation & Setup: Ubuntu, CentOS, Fedora & Debian
May 13, 2021

Introduction Fail2ban is a software that protects your server from brute force attacks. It does this by monitoring server logs and...
Read more
How to Use apt-get reinstall on Debian and Ubuntu
October 22, 2020

When packages are accidentally removed or modified on Debian or Ubuntu, reinstalling them usually resolves the problem. The --reinstall flag...
Read more
How to Change Hostname in Debian 10
August 11, 2021

You can change the hostname in Debian 10 (Buster) as the root user by using the built-in hostname command or editing related system files. learn how to change your hostname in this...
Read more