We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

How to Install Go on Debian 10

How to Install Go on Debian 10. Go also known as Golang is an open-source procedural programming developed by Google. Some popular applications that are written in Go are Docker, Kubernetes, Dropbox, Openshift, Netflix, Golang. Golang itself is written in Go.

In this guide you are going to learn how to install and setup Go language on Debian 10.

Step 1: Download Latest Go Binary

At the time of this writing the latest available version is go1.13 . You can check for the latest version and get the download link from the official golang website.

Run the following command to download go using wget.

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

Step 2: Install Go Language

Extract the downloaded archive it into /usr/local, creating a Go tree in /usr/local/go.

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

Add /usr/local/go/bin to the PATH environment variable by adding this line to your /etc/profile (for a system-wide installation) or $HOME/.profile for the current user installation.

Activate the environment variable to the current shell session using the following command.

source ~/.profile

Verify the installation using the following command.

go version
Output
go version go1.13.4 linux/amd64

This confirms Go language is installed in your server or system.

Step:3 Testing the Installation

Create your workspace directory, $HOME/go. (If you’d like to use a different directory, you will need to set the GOPATH environment variable.)

mkdir ~/go

Inside the go directory create these src/hello directories.

mkdir -p ~/go/src/hello

Now create a new file inside the hello directory with the name hello.go

nano  ~/go/src/hello/hello.go

Add these lines of code to the file.

package main

import "fmt"

func main() {
    fmt.Printf("hello, worldn")
}

Now move inside the hello directory and build the code using the go tool.

cd ~/go/src/hello
go build

This command will create a new executable in the current directory named as hello

Now execute the file to see the output.

./hello

Output
hello, world

Conclusion

Now you have installed and configured Go language and tested the installation by creating a new Go program which outputs Hello World.

18
1.399.885,35