How to Install Go on Debian 9

/ Category: Uncategorized / Comments: None

Spread the love

In this tutorial, we will guide you through the steps of installing Go on a Debian 9 Cloud VPS.

Go, also known as Golang, is a free and open-source programming language developed by Google. Go can be used to build simple, fast, reliable and efficient software applications. At the moment, Go is actually the most widely used programming language in the world. Many popular applications such as Docker, Openshift, and Graphana are all written in the Go language, along with thousands of smaller projects designed to fulfill and add extra features to other software. Go also allows us to run multiple processes of applications at the same time, improving performance and efficiency. Let’s begin with the installation.


  • A Debian 9 Cloud VPS. For the purposes of this tutorial we will use our LC VPS-1hosting plan.
  • A system user with root privileges, or the root

Step 1: Log in and Update Packages

Log in to your Debian 9 Cloud VPS via SSH as the root user (or as a user with sudo privileges). We can do that by entering this command:

ssh [email protected]<span style="color: #ff0000;">Server_IP_Address</span> -p <span style="color: #ff0000;">Port_Number</span>

Remember to replace ‘root’ with your username if you are not using the root user to log in. Change Server_IP_Address and Port_Number according to your server’s IP address and SSH port number.

Once logged in, you need to update all of the OS packages to their latest available versions by running the following commands:

apt update 
apt upgrade

As soon as all of your packages are up-to-date, we can then continue with the next step.

Step 2: Install Go

Go doesn’t come pre-installed on most of the Linux distributions. In the case of Debian 9, will have to install the latest version of the Go programming language from source.

Download the latest version of Go using the wget command:


Then, verify the downloaded file checksum with the sha256sum utility:

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

The output should be similar to the one below:

dbcf71a3c1ea53b8d54ef1b48c85a39a6c9a935d01fc8291ff2b92028e59913c go1.12.6.linux-amd64.tar.gz

Run the following command to extract the tarball into the /usr/local directory.

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

Step 3: Set up the Go Environment

Once the Go tarball is extracted, we need to set the PATH environment variable in order to find Go executable binaries by the system.

We can do this by editing the /etc/profile file (for a system-wide installation) or the $HOME/.profile file (for a current user installation). In this case, we’re going to set up Go to be available for all users.

nano /etc/profile

Append the following line:

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

Save and close the file. Then, apply the new PATH environment variable with the following command:

source /etc/profile

Step 4: Verify the Go Installation

That’s it! Once step 3 has been completed, Go has successfully installed and configured to work on a Debian 9 Cloud VPS.

We can now check the installed Go version with the following command:

go version

The output should be similar to the one below:

go version go1.12.6 linux/amd64

We can also check all of the Go environment variables that are currently configured by running the following command:

go env

The output should be similar to the following:

GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build527675922=/tmp/go-build -gno-record-gcc-switches"

A Simple Go Example: Hello World

We will create a simple program that simply outputs ‘Hello World’ to your terminal to show that the installation works and is ready to be used.

Open your favorite text editor (in our example we are using nano as our text editor) and create a file named hello-world.go:

nano hello-world.go

and then enter this code inside:

package main

import "fmt"

func main() {
    fmt.Println("Hello World")

This program is extremely simple. Save and close the file, then run it using Go:

go run hello-world.go

The output of this program should be:

Hello World

We can then build this simple program into a binary file. We can do this with the ‘go build’ command:

go build hello-world.go

Then, we can run the newly created binary directly as a native executable, like this:


The output should be the same as before.

That’s it! Go is now installed and fully functional on your Debian 9 Cloud VPS. For more details on how to use this platform, please check their official documentation – it’s extensive and should cover everything that you need.

You don’t need to set up Go by yourself if you use one of our Managed Debian Cloud Hosting solutions. Instead, you can simply ask our expert Linux admins to set up Go on Debian 9 for you. They are available 24×7 and will take care of making sure that it’s ready to go for your project, along with any other requests that you might have.

If you found this tutorial helpful, please share it with your friends through social media by using the share shortcuts, or if you have any questions or comments, feel free to leave a comment in the comments section. Thanks.

Be the first to write a comment.

Your feedback