How to install the Golang on Ubuntu Cloud Servers

2021-03-30 By Mark 56 Views linux golang development
0 reviews

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 Ubuntu system.

  1. Take SSH access to the Ubuntu Cloud server as root or a sudo user.

  2. Run the below command to update the server first before proceed the installation.

    # apt-get update


  3. Change to a temporary directory and select the latest package for your architecture from the following and download.

    # cd /tmp
    # wget


  4. Now extract the Golang executable to the /usr/local directory.

    # tar -C /usr/local -xzf gol.16.2.linux-amd64.tar.gz


  5. 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


  6. Now Reload your profile with the below command to begin using Golang.

    # source ~/.profile


  7. Verify the version of Golang with the below command.

    # go version


  8. 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 created, then run the below command to run the programe.

    # go layerstack.go


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

What do you think about this article?

Rate this article