How to Install Go (Golang) on Debian 12?
Go, also renowned as Golang, is a powerful as well as versatile programming language that has attained popularity among developers. Its purpose is to streamline software development, making it safe, fast, and approachable for building reliable and efficient software.
Installing it on Debian 12 is a smart choice due to its lightweight goroutines. They enable concurrent programming, making it ideal for programs/applications (acquiring efficient memory management and high performance).
Based on its significance, this blog will explain all possible ways to install Go (Golang) on Debian 12.
How to Install Go (Golang) on Debian 12?
Go is designed for speed and efficiency. It compiles quickly and executes code with minimal overhead, making it suitable for various applications. Let’s explore the different ways to install Go (Golang) on Debian 12.
- Method 1: Using Default Repository Package
- Method 2: Using the Official Website
- Method 3: Using Snap
Here starts the installation of Go on Debian 12 with the first method.
Method 1: Install Go (Golang) on Debian 12 Using Default Repository Package
Go allows programmers/developers to write concurrent and efficient programs. It is available in the default Debian 12 repository. Track these steps for installation:
Step 1: Update Debian Packages
Before installing Golang, ensure your system is upgraded/up-to-date:
sudo apt update
Step 2: Find the Golang Package
Now, search the Golang package details, including the version via the “apt show” utility:
sudo apt show golang
Step 3: Install Golang
The easiest method is to use the default repository package. Now, install Golang from the default repository using apt:
sudo apt install golang
Step 4: Verify GO Installation
Users can check the successful installation of go via the “version” utility as below:
go version
Optional: Remove/Uninstall Go
Users can uninstall/remove Go from the Debian system by executing the below command:
sudo apt remove golang # Remove Go Package Only sudo apt purge golang # Remove Go Package as well as Dependencies sudo apt autoremove golang # Completely Remove Go
That is all from the first method. Let’s move towards another method.
Method 2: Install Go (Golang) on Debian 12 Using the Official Website
Go is well-suited for building scalable systems. Its standard library makes it an ideal option for cloud-native applications. Users download the installation package directly from the official Go website. To install Go (Golang) on Debian 12, follow these steps:
Step 1: Update Debian
Before installing Go, ensure your system is up-to-date. For this, run the following commands:
sudo apt update sudo apt upgrade
Step 2: Download Golang
Visit the official Go website to download the latest version. At this time, the latest version is 1.22.0. Once you’ve identified the appropriate version for Linux, copy the URL of the corresponding download link:
wget https://go.dev/dl/go1.22.0.linux-amd64.tar.gz
Note: Users prefer the (available) latest version during download from the official website.
Step 3: Extract tar Package
Extract the downloaded (.tar.gz) archive and copy its contents into /usr/local. This is for creating a Go tree (fresh):
sudo tar -C /usr/local -xzf go1.22.0.linux-amd64.tar.gz
Step 4: Set Up Golang (PATH)
After installation, add Go’s (binary) directory to the PATH (environment variable). For instance, add the below line to the $HOME/.profile or /etc/profile:
export PATH=$PATH:/usr/local/go/bin
Optional: For applying the changes instantly, users can execute the below shell command:
source $HOME/.profile
Step 5: Verify Installation
Finally, users can check the Go version by executing the following command:
go version
In this way, Go has been installed on Debian.
Method 3: Install Go (Golang) on Debian 12 Using Snap
Go’s syntax is straightforward to learn. It emphasizes readability, which reduces the cognitive load for developers. Snapcraft is a Linux application store that contains various Linux snaps. To install Go using Snapcraft, follow these steps:
Step 1: Install Snap
First, install the snapd (package manager), which is utilized for managing Linux application snaps:
sudo apt install snapd
Step 2: Download and Install Golang Snap
Next, download and install the Go snap using the following command. The Go programming language snap is successfully installed with the “1.22.0” version:
sudo snap install go --classic
Step 3: Verify GO Installation
To verify that Go is installed, display the installed version via the “snap list” utility. Now, you have to Go install on your Debian 12 system:
snap list
Optional: Remove Go
If you ever need to remove Go, remove Go using snapd, by executing the following command:
sudo snap remove go
That’s it! You’re all set to develop efficient, reliable, and scalable software using Go on Debian 12.
Features of GO
Go is a modern, efficient, and powerful language that’s famous among programmers/developers. Some of the features are given below:
- Go covers essential functionalities. Developers can leverage these packages without relying heavily on third-party libraries.
- Go has a vibrant community and active forums. It’s backed by Google and has gained traction in various domains.
- Go is popular for building block chain applications because of its security features as well as performance.
- Go has database drivers that enable seamless interaction with databases.
- Developers can build machine learning solutions using Go.
To explore the installation of GO on Ubuntu, follow our guide.
Conclusion
To install Go (Golang) on Debian 12, use the default repository package via the “sudo apt install golang” command. Or, download as well as install the (recent-release) latest version of Go from the official website. Alternatively, use Snapcraft to install Go. Installing Go provides access to a powerful language that simplifies software development, supports concurrency, and offers scalability for modern applications. However, I recommend the default repository package for simplicity. This guide has explained possible methods to install Go (Golang) on Debian 12.