Home » PHP » How to Install Go on Debian 8 Linux

How to Install Go on Debian 8 Linux

Go is a very new and most popular open-source programming language; Google creates it. There are many popular software/applications developed using the Go language, including Grafana, Docker, Kubernetes, and many more.

In this tutorial, we will go through the process of setting the Go language environment in your Debian 8 Linux from download to install step-by-step.

Prerequisites

Before starting the installation process, Go, make sure your system runs on Debian 8 Linux, and has user access with sudo privileges to execute administrative commands.

Installing Go on Debian 8 Linux

The Go language installation and configuration in Debian Linux is very easy; you can download and install Go into Debian Linux in the few steps.

Follow the below steps to install Go on Debian 8:

Step 1 – Downloading the Go tarball package.

Currently, the latest version of Go Language is 1.15.2 available; before downloading the tarball package, you can visit the official downloading page of Go and check available new version available.

You can download the Go binary, using either curl or wget command:

$ wget https://dl.google.com/go/go1.15.2.linux-amd64.tar.gz

Step 2 – Verify the Go tarball package.

You can verify the tarball checksum using the sha256sum command, as shown below:

$ sha256sum go1.15.2.linux-amd64.tar.gz

You will get the output similar like below:

output:
68a2297eb099d1a76097905a2ce334e3155004ec08cdea85f24527be3c48e856  go1.15.2.linux-amd64.tar.gz

You should make sure the printed hash from the above command matches one from the download package mention on the download page.

Step 3 – Extract Go package.

You can use the tar command to extract the tarball package to the /usr/local directory, as shown below:

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

Step 4 – Configure the Path Variable

The Debian operating system needs to manage Path for all executable programs to find the program’s executable binaries.

To configure Go executable binaries, PATH needs to adjust the $PATH environment variable. You can do this by appending the below line in the /etc/profile file:

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

After adding the line, save the file and load the new PATH environment variable into the same shell session using the following command:

$ source ~/.profile

Step 5 – Verify the Go Installation

You can verify the Go programming language installation on the Debian system by checking the version as shown below:

$ go version

You will get the output similar like below:

output:
go version go1.15.2 linux/amd64

Go Language basics

In Go Language’s basic uses, we will set up a workspace and create a simple program, “program1,” that will print the message “hello world.”

To create a Go program, we will follow these four steps:

Step 1 – Create a Go workspace.

By default, we creating workspace directory is in the user’s home directory $HOME/go. To create it, use the following command:

$ mkdir ~/go

Step 2 – Create a program directory under the workspace.

It would be best if you created a new directory src/program1 inside the workspace, as shown below:

mkdir -p ~/go/src/program1

In the newly-created directory (program1), create a file named hello.go with the following go program:

package main
import "fmt"
func main() {
    fmt.Printf("Hello, World\n")
}

If you want to learn more about the Go workspace directory hierarchy, please check this link.

Step 3 – Build a Go program.

To build the go application for the program, navigate to the ~/go/src/hello directory, and make a file using the go build command, as shown below:

$ cd ~/go/src/hello
$ go build

The above command will build and an executable file named program1.

Step 4 – Run the new Go program.

You can execute the new build program by running the command, as shown below:

./hello

You will get the output similar like below:

output:
Hello, World

Conclusion

Now you learn to download and install Go language in Debian 8 Linux and learn to build workspace, write and run Go programs.

If you get any problem or having any feedback, please comment below.

Related Posts

How to Install MongoDB on Debian 10 Linux

How to Install MongoDB on Debian 10 Linux

MongoDB is an open-source and free NoSQL document based database system. Nowadays, it is prevalent as most application developers are using MongoDB, which can handle big data. As a MongoDB is a NoSQL database, It stores data in JSON-like documents where fields can...

How to Setup a Firewall with UFW on Debian 10 Linux

How to Setup a Firewall with UFW on Debian 10 Linux

Nowadays, a Firewall is an essential utility and property of any system for security; by default Debian Operating system having a firewall configuration tool named UFW (Uncomplicated Firewall). UFW is a user-friendly front-end tool to manage iptables firewall rules....

How to Install Eclipse IDE on Debian 10 Linux

How to Install Eclipse IDE on Debian 10 Linux

Eclipse is the most famous and widely used Java integrated development environment (IDE). It supports many plugins to enhance the capabilities to use for other programming language development environments such as PHP, C++, and JavaScript. You can install Eclipse IDE...

How to Install Ruby on Debian 10 Linux

How to Install Ruby on Debian 10 Linux

Nowadays, Ruby is the most popular language, especially for SaaS application development. It has a perfect and elegant syntax structure, and it is the language behind the ultimate robust framework known as Ruby on Rails. In this tutorial, we will explain the three...

0 Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

5 − 3 =

Follow Us

Our Communities

More on Debian

The Ultimate Managed Hosting Platform
Load WordPress Sites in as fast as 37ms!