DebianLinuxTutorials

How To Install Go on Debian 10

Install Go on Debian 10

In this tutorial, we will show you how to install Go on Debian 10. For those of you who didn’t know, Go, also known as Golang, is an open-source programming language developed by Google. Designed for simplicity, efficiency, and scalability, Go has gained immense popularity among developers for building robust and high-performance applications. Whether you’re a seasoned programmer or just starting your coding journey, installing Go on your Debian 10 system is a straightforward process.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Go open-source programming language on a Debian 10 (Buster).

Prerequisites

  • A server running one of the following operating systems: Debian 10 (Buster).
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Go on Debian 10 Buster

Step 1. It’s always a good practice to update your system’s package index and installed packages before introducing new software. This ensures that you have the latest security patches and bug fixes, minimizing potential conflicts or compatibility issues.

To update the package index, open your terminal and run the following command:

sudo apt update

Step 2. Installing Required Dependencies.

Go’s installation process requires the curl utility, which is used to download files from the internet. If curl is not already installed on your system, you can install it by running the following command:

sudo apt install curl

Step 3. Installing Go on Debian 10.

Now we go to Go’s download page and grab a link for the latest version:

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

To verify the integrity of the downloaded file, you can use the sha256sum command and compare the output with the official SHA256 checksum provided on the Go downloads page. Run the following command:

sha256sum go1.22.3.linux-amd64.tar.gz

If the hash matches the official release, you can proceed with the installation.

Next, extract the tar archive to the /usr/local directory:

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

Then, set the path environment variable in order to find Go executable binaries by the system. For that, we need to open /.bash_profile using the below command:

sudo nano ~/.bash_profile

Add the below lines:

export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin

Save and close the file. After that run the below command to reload the running profile:

source ~/.bash_profile

Here comes the easy bit, let’s check our installed go version:

$ go version
go version go1.22.3 linux/amd64

To further confirm that Go is working as expected, create a simple “Hello, World!” program. Open your text editor and create a new file named hello.go in your $GOPATH/src directory (e.g., $HOME/go/src/hello.go). Add the following code to the file:

package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

Save the file and close the text editor. In your terminal, navigate to the directory containing the hello.go file:

cd $GOPATH/src

Compile the program by running:

go build hello.go

This will create an executable binary named hello (or hello.exe on Windows) in the same directory.

Finally, run the compiled program:

./hello

If you see the output “Hello, World!” in your terminal, congratulations! You have successfully installed and configured Go on your Debian 10 system.

Congratulations! You have successfully installed Go (Golang). Thanks for using this tutorial for installing the latest version of the Golang open-source programming language on the Debian system. For additional help or useful information, we recommend you check the official Go website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button