Golang (Go) is a powerful system-level language used for programming across large network servers and large distribution systems. It was previously written in C but is now written in Go itself. This tested and proves that the applications written in Go are very performance and scalable.
This guide will describe the installation of the Latest Version of Golang on the Ubuntu system.
Take SSH access to the Ubuntu Cloud server as root
or a sudo user
.
Run the below command to update the server first before proceeding with the installation.
# apt-get update

Change to a temporary directory and select the latest package for your architecture from the following https://golang.org/dl/ and download.
# cd /tmp
# wget https://golang.org/dl/go1.16.2.linux-amd64.tar.gz

Now extract the Golang executable to the /usr/local
directory.
# tar -C /usr/local -xzf gol.16.2.linux-amd64.tar.gz

To use Golang, set the below environment variables in your .profile
.
# echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.profile
# echo "export GOPATH=~/.go" >> ~/.profile

Now Reload your profile with the below command to begin using Golang.
# source ~/.profile

Verify the version of Golang with the below command.
# go version

To test the environment, create a go file
.
# vi layerstack.go
Paste the below simple programe in that file:
package main
import "fmt"
func main() {
fmt.Println("Welcome to Layerstack")
}
Once it is created, then run the below command to run the program.
# go layerstack.go

NOTE: You can change any file name as you need.