Logo
  • Ubuntu
  • CentOS
  • Debian
  • Fedora
  • RedHat

How to Install Go on Ubuntu 22.04 - DesignLinux

Nov 19 2022
designlinux 0 Comments
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.

Related

Tags: go, ubuntu

How to Install GCC on Ubuntu 22.04

Prev Post

How to Install Git on Debian 11 Linux

Next Post
Archives
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • July 2022
  • June 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
Categories
  • AlmaLinux
  • Android
  • Ansible
  • Apache
  • Arch Linux
  • AWS
  • Backups
  • Bash Shell
  • Bodhi Linux
  • CentOS
  • CentOS Stream
  • Chef
  • Cloud Software
  • CMS
  • Commandline Tools
  • Control Panels
  • CouchDB
  • Data Recovery Tools
  • Databases
  • Debian
  • Deepin Linux
  • Desktops
  • Development Tools
  • Docker
  • Download Managers
  • Drupal
  • Editors
  • Elementary OS
  • Encryption Tools
  • Fedora
  • Firewalls
  • FreeBSD
  • FTP
  • GIMP
  • Git
  • Hadoop
  • HAProxy
  • Java
  • Jenkins
  • Joomla
  • Kali Linux
  • KDE
  • Kubernetes
  • KVM
  • Laravel
  • Let's Encrypt
  • LFCA
  • Linux Certifications
  • Linux Commands
  • Linux Desktop
  • Linux Distros
  • Linux IDE
  • Linux Mint
  • Linux Talks
  • Lubuntu
  • LXC
  • Mail Server
  • Manjaro
  • MariaDB
  • MongoDB
  • Monitoring Tools
  • MySQL
  • Network
  • Networking Commands
  • NFS
  • Nginx
  • Nodejs
  • NTP
  • Open Source
  • OpenSUSE
  • Oracle Linux
  • Package Managers
  • Pentoo
  • PHP
  • Podman
  • Postfix Mail Server
  • PostgreSQL
  • Python
  • Questions
  • RedHat
  • Redis Server
  • Rocky Linux
  • Security
  • Shell Scripting
  • SQLite
  • SSH
  • Storage
  • Suse
  • Terminals
  • Text Editors
  • Top Tools
  • Torrent Clients
  • Tutorial
  • Ubuntu
  • Udemy Courses
  • Uncategorized
  • VirtualBox
  • Virtualization
  • VMware
  • VPN
  • VSCode Editor
  • Web Browsers
  • Web Design
  • Web Hosting
  • Web Servers
  • Webmin
  • Windows
  • Windows Subsystem
  • WordPress
  • Zabbix
  • Zentyal
  • Zorin OS
Visits
  • 7
  • 748
  • 610,107

DesignLinux.com © All rights reserved

Go to mobile version