• 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 22.04

Written by Admin, Updated On January 7, 2023
go, ubuntu
How to Install Go on Ubuntu 22.04

Go, or golang is a cross-platform and open source programming language developed by Google Engineers. Many popular applications such as Kubernetes, Terraform, Rancher, Docker, etc. are written in Go language. This article explains how to install Go on Ubuntu 22.04 Jammy Jellyfish.

How install Go on Ubuntu 22.04#

Perform the following steps to install Go on Ubuntu 22.04:

Step 1 – Download Go

The latest version of Go language is 1.19.3. It’s advisable to check latest version at official download page if any available. You should run the below command as root or sudo user to download Go binary archive using wget:

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

Step 2 – Set Go Path Variable

After that 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.

Now, 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

To check the installation use the below command:

go version

It should show output as following:

go version go1.19.3 linux/amd64

Step 4 – Create Test Program

We will create a simple program to check GO installed properly, which will print “Welcome to GO” message. Perform following 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 22.04 Jammy Jellyfish 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 GCC on Ubuntu 22.04
Next Article   How to Install Git on Debian 11 Linux

Related Posts

  • How to Install Apache, MySQL, PHP (LAMP) on Ubuntu 22.04

    How to Install LAMP on Ubuntu 22.04

    March 20, 2023
  • How to Install LEMP Stack on Ubuntu 22.04

    How to Install LEMP Stack on Ubuntu 22.04

    March 18, 2023
  • How to Install Memcached on Ubuntu 22.04

    How to Install Memcached on Ubuntu 22.04

    March 16, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install PHP 8.2 on Debian 11
    How to Install PHP 8.2 on Debian 11 Linux February 24, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 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