• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install Go on Ubuntu 20.04

Written by Admin, Updated On May 3, 2020
go, ubuntu
How to Install Go on Ubuntu 20.04

Go, or golang is a modern open source programming language developed by Google. Many popular applications such as Kubernetes, Terraform, Rancher, Docker, etc. are written in Go language. This guide explains how to install Go on Ubuntu 20.04 Focal Fossa.

Install Go on Ubuntu 20.04#

Perform the following steps to install Go on Ubuntu 20.04:

Step 1 – Download Go#

Go 1.14.2 is the latest version available currently. It’s recommended to check latest version at official download page if any available. Run the below command as root or sudo user to download Go binary archive using wget:

wget -c https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz -O - | sudo tar -xz -C /usr/local

Step 2 – Set Go Path Variable#

Now we will set location of the Go directory to the $PATH environment variable. So it will help system to know where to find the Go executable binaries.

Edit the /etc/profile file for global installation or $HOME/.profile file for a current user installation:

export PATH=$PATH:/usr/local/go/bin

Save and close the file.

Next, load the new PATH environment variable into the current shell session:

source ~/.profile

Step 3 – Verify Installation#

Verify the Go installation using Go version command:

go version

Output should look like this:

go version go1.14.2 linux/amd64

Step 4 – Create Test Program#

To test GO is properly installed, you can create a simple program which will print “Welcome to GO” message. Follow below steps to build simple program.

First of all, create a workspace directory for Go. You can get more details about go workspace directory visit this page:

mkdir ~/go

Next, create a directory src/welcome inside it using below command:

mkdir -p ~/go/src/welcome

In this directory create a file named welcome.go and add below content to it:

sudo nano ~/go/src/welcome/welcome.go
package main
import "fmt"
func main() {
    fmt.Printf("Welcome to GO\n")
}

Now go back /go/src/welcome to build the file and issue go build command:

cd ~/go/src/welcome
go build

The above command will build an executable file with name welcome.

You can run the program using executable using following command:

./welcome
Welcome to GO

Conclusion#

You successfully learn how to install GO on Ubuntu 20.04 Focal Fossa system.

If you have any queries or suggestion, feel free to comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install VirtualBox Guest Additions on Debian 10
Next Article   How to Install Pip on CentOS 8

Related Posts

  • How to Install and Use PHP Composer on Ubuntu 22.04

    How to Install Composer on Ubuntu 22.04

    January 31, 2023
  • How to Install Nginx on Ubuntu 22.04

    How to Install Nginx on Ubuntu 22.04

    January 28, 2023
  • How to Install Puppet Agent on Ubuntu 22.04

    How to Install Puppet Agent on Ubuntu 22.04

    January 22, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install SSH Keys on Ubuntu 22.04
    How to Set up SSH Keys on Ubuntu 22.04 January 7, 2023
  • How to Install Mongodb on Debian 11
    How to Install MongoDB on Debian 11 Linux January 11, 2023
  • How to Install Puppet Agent on Ubuntu 22.04
    How to Install Puppet Agent on Ubuntu 22.04 January 22, 2023
  • How to Install Python 3.11 on Debian 11
    How to Install Python on Debian 11 January 25, 2023
  • How to Change-Hostname Ubuntu 22.04
    How to Change Hostname on Ubuntu 22.04 January 19, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook