Share your love
How To Set up Golang on Debian 11

In this article, we want to teach you How To Set up Golang on Debian 11. Golang is an open-source programming language created by Google. This language has gained immense fame because of its top-notch security, concurrency, and user-friendliness. Golang combines the notable performance and top security features of C++ with the speed of Python.
You can now follow the guide steps below on the Orcacore website to set up Golang on Debian 11.
Table of Contents
Set up Golang on Debian 11
Before you start to install Golang on Debian 11, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our article The Initial Server Setup with Debian 11.
Now, follow the steps below to install Golang on Debian 11.
1. Download and Install Golang on Debian 11
First, you need to update your local package index with the command below:
sudo apt update && sudo apt upgrade -y
Then, you need to visit the Go Downloads page to check the latest version of Golang.

Next, install the wget tool on your server to download the Go:
sudo apt install wget -y
Now use the following command to download Golang on your Debian 11:
sudo wget https://go.dev/dl/go1.24.5.linux-amd64.tar.gz
Extract your Golang downloaded file to the /usr/local directory with the command below:
sudo tar -zxvf go1.24.5.linux-amd64.tar.gz -C /usr/local/
At this point, you need to set the PATH environment variable to include Go’s bin directory. To do this, run the following command:
sudo echo "export PATH=/usr/local/go/bin:${PATH}" | sudo tee /etc/profile.d/go.sh
Next, you need to source the file with the command below:
sudo source /etc/profile.d/go.sh
Verify your Golang installation on Debian 11 by checking its version:
go version
In your output, you will see:
Output
go version go1.24.5 linux/amd64
Also, you can check the Golang environment variables on Debian 11:
go env
In your output, you will see:

2. Create a Sample Project with Golang
At this point, we will show you how to use Golang by creating your first project. First, create a hello directory for your project with the command below:
sudo mkdir -p hello
Switch to your directory:
cd hello
Then, create a simple program to test your Golang installation on Debian 11. Create the file with your favorite text editor; here, we use the vi editor:
sudo vi hello.go
Add the following content to your file:
package main
import "fmt"
func main() {
fmt.Printf("Welcome To orcacore\n")
}
When you are done, save and close the file.
Now you need to build go.mod files so that you can execute the Golang file that you have created on Debian 11:
sudo vi go.mod
Add the following line to the file:
module example.com/mod
When you are done, save and close the file.
Build the program with the command below:
sudo go build
Then, execute the program with the following command:
sudo ./mod
In your output, you will see:
Output
Welcome To orcacore
Conclusion
Installing Go (Golang) on Debian 11 is a straightforward process that sets up a powerful development environment for building fast, efficient, and scalable applications. With Go installed, you can explore its capabilities for building web apps, APIs, CLI tools, and more.
Hope you enjoy it. Please subscribe to us on Facebook, YouTube, and X.
May you be interested in these articles:
Install and Configure LibreNMS on Debian 11
Install and Configure Django on Debian 11