How to Install Go on Debian 12
Introduction
Go, or Golang, is a relatively new, open-source language created by Google. Its purpose is to streamline software development and enable users to create simple and reliable apps.
As a modern language, Go offers memory allocation, concurrency support, garbage collection, coordination avoidance, etc.
This article explains how to install Go on Debian 12 in a few simple steps.
Prerequisites
- Debian system (this tutorial uses Debian 12).
- A sudo user.
- Access to the command line.
How to Install Go on Debian 12
Before starting the installation, ensure the Debian server is up to date. Update the repository with the following:
sudo apt update -y
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.
Note: Use wget or curl to download Go without accessing the browser.
Step 2: Extract Files
Extract files to the /usr/local directory. To do that, take the following steps:
cd ~/Downloads
2. Run the following command to extract files:
sudo tar -C /usr/local -xzf go1.22.5.linux-amd64.tar.gz
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.
vim .profile
2. At the end of the file, paste the following lines:
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
3. Save and close the file.
4. Reload your shell configuration to apply the changes with:
source ~/.profile
The command has no output.
Note: To install Go system-wide, edit /etc/profile. To install it for the current user, access $HOME/.profile.
No Comments