Saturday, October 31, 2020

How to Install Go on Debian 10 Linux

Must read

How to Setup a Firewall with UFW on Ubuntu 20.04

Nowadays, a Firewall is an essential utility and property of any system for security; by default Ubuntu Operating system having a firewall...

How to Install Ruby on Ubuntu 20.04 Linux

Nowadays, Ruby is the most popular language, especially for SaaS application development. It has a perfect and elegant syntax structure, and it...

How to Install Eclipse IDE on Ubuntu 20.04 Linux

Eclipse is the most famous and widely used Java integrated development environment (IDE). It supports many plugins to enhance the capabilities to...

The 30 most useful Linux commands

This article will introduce some practical and common Linux or Unix command , which is the Linux system administrators normally use the command . This article is not a...
SATISH KUMAR
I am Satish Kumar, Founder of LinuxConcept. Linux and F.O.S.S enthusiast, love to work on open source platform and technologies.
- Advertisement -

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 10 Linux from download to install step-by-step.

Prerequisites

- Advertisement -

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

Installing Go on Debian 10 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 10:

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.

- Advertisement -

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
- Advertisement -

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 10 Linux and learn to build workspace, write and run Go programs.

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

- Advertisement -
- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Subscribe to our newsletter

To be updated with all the latest news, offers and special announcements.

Latest article

How to Setup a Firewall with UFW on Ubuntu 20.04

Nowadays, a Firewall is an essential utility and property of any system for security; by default Ubuntu Operating system having a firewall...

How to Install Ruby on Ubuntu 20.04 Linux

Nowadays, Ruby is the most popular language, especially for SaaS application development. It has a perfect and elegant syntax structure, and it...

How to Install Eclipse IDE on Ubuntu 20.04 Linux

Eclipse is the most famous and widely used Java integrated development environment (IDE). It supports many plugins to enhance the capabilities to...

The 30 most useful Linux commands

This article will introduce some practical and common Linux or Unix command , which is the Linux system administrators normally use the command . This article is not a...

How to Reset the MySQL Root Password

Do you want to reset the MySQL root password? Sometimes we forget the root password and not able to log in on...