Kiến Thức Linux

How to Install Go on Debian

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.

Đăng ký liền tay Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !

Add Comment

Click here to post a comment

Đăng ký liền tay
Nhận Ngay Bài Mới

Subscribe ngay

Cám ơn bạn đã đăng ký !

Lỗi đăng ký !