How to install the Golang on Ubuntu Cloud Servers

2021-03-30 By Mark 1536 Views linux golang development
4 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 the 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 proceeding with the installation.

    # apt-get update
    

    golang1

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

    golang2

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

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

    golang3

  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
    

    golang4

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

    # source ~/.profile
    

    golang5

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

    # go version
    

    golang6

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

    # go layerstack.go
    

    golang7

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

What do you think about this article?

Rate this article
Need assistance?

Try this guide to receive free bundled services at signup on a new free account.

Sign Up

Your Feedback Is Important

We hope you’ll give the new products and updates a try. If you have an idea for improving our products or want to vote on other user ideas so they get prioritized, please submit your feedback on our Community platform. And if you have any questions, please feel free to ask in the Community or contact our Technical Support team.