• About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap
Linux Tutorials for Beginners
Advertisement
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
No Result
View All Result

Home » Ubuntu » How To Install and Configure Go (Golang) on Ubuntu 22.04

How To Install and Configure Go (Golang) on Ubuntu 22.04

sammbysamm
October 16, 2023
Install Go on Ubuntu

How To Install and Configure Go (Golang) on Ubuntu 22.04

Share on FacebookShare on LinkedinShare on Whatsapp

Introduction

In the world of programming, efficiency and performance are key factors that can greatly impact the success of any project. One programming language that has gained immense popularity for its speed and efficiency is Go, also known as Golang. Developed by Google, Go is designed to provide developers with a reliable and robust platform for building efficient and scalable software. In this article, we will walk you through a step-by-step guide on how to install and configure Go on Ubuntu 22.04 to ensure optimal performance.

Table of Contents

  • Introduction
  • Prerequisites
  • Installing Go on Ubuntu 22.04
  • Method 1: Using Apt Command
    • Step 1: System Update
    • Step 2: Install Go on Ubuntu 22.04
  • Method 2: Install Go from Binary File
    • Step 1: Download Go
    • Step 2: Add the Golang binary to the $PATH
  • How to use Go in Ubuntu 22.04
  • Conclusion

Go is commonly used for various purposes, such as web development, networking applications, system programming, cloud services, and containerization (e.g., Docker). Its popularity in the software industry continues to grow due to its performance, simplicity, and strong concurrency support, making it an attractive choice for modern application development.

OTHER POSTS

How To Install and Secure phpMyAdmin on Ubuntu 22.04

How To Secure SSH with Fail2Ban on Ubuntu 22.04

How To Install Uptime Kuma on Ubuntu 22.04

Prerequisites

  • Ubuntu 22.04. Before you begin, you should have a non-root user account with sudo privileges set up on your system. You can learn how to do this by following the Initial Server Setup Guide with Ubuntu 22.04 tutorial.
  • It would help if you used a fresh OS install to prevent potential issues.

Installing Go on Ubuntu 22.04

Go is a programming language developed by Google. It’s an open-source, statically typed, compiled language which provides garbage collection, memory safety, and concurrency.

There are several methods to install Go on Ubuntu 22.04 and the details of each method are given below:

This tutorial explains how to install Go on Ubuntu 22.04.

Method 1: Using Apt Command

The apt package management system in Ubuntu 22.04 includes the repository of Go, thus allowing the user to install the latest version of software directly from the apt command. You can use the following installation command to install Go on Ubuntu:

Step 1: System Update

Before we begin, it’s essential to ensure that your system packages are up to date. Open a terminal and run the following commands:

samm@go:~$ sudo apt-get update -y 

Running the update command will inform you of the number of packages that need to be upgraded. However, you can choose to skip this step if there are no packages to upgrade.

samm@go:~$ sudo apt-get upgrade -y

Step 2: Install Go on Ubuntu 22.04

If you are curious enough, you can search for the availability of the golang-go package from Debian / Ubuntu repositories as shown.

samm@go:~$ apt search golang-go

Output :

Sorting... Done
Full Text Search... Done
gccgo-go/jammy 2:1.18~0ubuntu2 amd64
  Go programming language -- gccgo

gogoprotobuf/jammy 1.3.2-1 amd64
  alternative protocol buffer support for Golang - utilities

golang-1.17/jammy-updates 1.17.13-3ubuntu1 all
  Go programming language compiler - metapackage

golang-1.17-go/jammy-updates 1.17.13-3ubuntu1 amd64
  Go programming language compiler, linker, compiled stdlib

golang-1.18/jammy-updates,jammy-security 1.18.1-1ubuntu1.1 all
  Go programming language compiler - metapackage

golang-1.18-go/jammy-updates,jammy-security 1.18.1-1ubuntu1.1 amd64
  Go programming language compiler, linker, compiled stdlib

golang-1.20/jammy-updates 1.20.3-1ubuntu0.1~22.04 all
  Go programming language compiler - metapackage

golang-1.20-go/jammy-updates 1.20.3-1ubuntu0.1~22.04 amd64
  Go programming language compiler, linker, compiled stdlib
......

To install Golang Go using apt command, run

samm@go:~$ sudo apt install golang-go

Output :

samm@go:~$ sudo apt install golang-go
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
The following additional packages will be installed:
golang-1.18-go golang-1.18-src golang-src pkg-config
Suggested packages:
bzr | brz mercurial subversion
The following NEW packages will be installed:
golang-1.18-go golang-1.18-src golang-go golang-src pkg-config
0 upgraded, 5 newly installed, 0 to remove and 11 not upgraded.
Need to get 82.4 MB of archives.
After this operation, 437 MB of additional disk space will be used.
Do you want to continue? [Y/n]

Press “Y“ to continue installation.

Once the installation is complete, verify that Go is installed as shown.

samm@go:~$ go version
go version go1.18.1 linux/amd64

From the output, you can see that Go version 1.18.1 has been installed. Notably, this is not the latest version at the time of writing this guide.

Method 2: Install Go from Binary File

You can use this method to install the latest version of Go on Ubuntu 22.04. For that purpose, you will need to follow the steps given below:

Step 1: Download Go

Start by visiting the official download page Go to download the latest stable version of Go and download the 64-bit tarball installation file (amd64.tar.gz)

On the command line, you can download the latest tarball file using the wget command. At the time of writing this guide, the latest version of Go is Go 1.20.7. This is likely to change by the time you are reading this guide, so ensure to replace the version number accordingly.

samm@go:~$ curl -o go.tar.gz "https://dl.google.com/go/$(curl https://go.dev/VERSION?m=text).linux-amd64.tar.gz"

Once the download is complete, extract the tar.gz file to the /usr/local directory:

samm@go:~$ sudo tar xf go.tar.gz -C /usr/local

Step 2: Add the Golang binary to the $PATH

The next step is to specify where Go binaries are located. Add the /usr/local/go/bin directory to the system’s PATH environment variable. It can be set in /etc/profile file. In this case, Go will be available for all users as a system-wide command. To achieve this, run the following command:

samm@go:~$ vi ~/.bashrc

Paste the following line.

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

Save the changes and exit the file.

Next, to make changes to take effect, reload the .bashrc or .bash_profile file using the source command as shown.

samm@go:~$ source ~/.bashrc

To ensure the installation was successful, we will check the version of “Go.”
To do this, execute the “go” command together with the “version” option on the terminal as shown below:

samm@go:~$ go version
go version go1.20.7 linux/amd6

The following output shows that go has successfully been installed.

How to use Go in Ubuntu 22.04

After completing the Go installation, proceed to execute a simple code written in the Go language. This test will determine whether the environment is functioning correctly on Ubuntu.

We will create a separate directory for our project as follows.

samm@go:~$ mkdir go-project

Now go to the directory and run the example module using the following commands:

samm@go:~$ cd go-project/

We will create a simple program called hai.go that prints out a simple message on the terminal.

samm@go:~/go-project$ vi hai.go

Copy and paste the following lines of code into the file.

package main
import "fmt"
func main() {
    fmt.Printf("Congratulations samm!! Go has successfully been installed on your system\n")
}

Save the changes and exit. Then run the program as follows

samm@go:~/go-project$ go run hai.go

You will get the following output. This confirms that the installation of Golang Go is working as expected.

Congratulations samm!! Go has successfully been installed on your system
Install Go on Ubuntu
Sample Project Go

That’s it, now you can execute other codes using the same method on Ubuntu 22.04. For further guidance, you can read the Go Documentation.

Conclusion

Congratulations! You have successfully installed and configured Go on your Ubuntu 22.04 system. Go’s performance-oriented design and simplicity make it a powerful tool for developing efficient applications. By following the steps outlined in this guide, you’ve set up a solid foundation for building high-performance software using the Go programming language. Start exploring Go’s extensive libraries and tools to unlock its full potential in your projects. Happy coding!

Also Read Our Other Guides :

  • How To Install and Configure Elasticsearch on Ubuntu Server 22.04
  • How To Install and Configure NFS Server Client on Ubuntu 22.
  • How To Install Jenkins on Ubuntu 22.04
  • How To Install a MinIO Object Storage Server on Rocky Linux

Finally, now you have learned how to install and configure Go (Golang) on Ubuntu 22.04.

Tags: GoGolangLinuxProgramming LanguageUbuntu

If you got help by our tutorials, please buy me a coffee..!

Buy Me a Coffee

Thank you so much for your support!!

Previous Post

How To Install VirtualBox 7.0 on Ubuntu 22.04

Next Post

How To Install Composer in Ubuntu 22.04: A Comprehensive Guide

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

RECENT POST

Install and Secure phpMyAdmin on Ubuntu 22.04

How To Install and Secure phpMyAdmin on Ubuntu 22.04

by samm
July 22, 2024
0

Are you ready to take control of your MySQL databases on Ubuntu 22.04? In this step-by-step guide, we'll walk you...

Manage Groups on Linux

A Simple Guide: How To Manage Groups on Linux

by samm
November 12, 2023
0

Are you a Linux enthusiast looking to enhance your system administration skills? One fundamental aspect you should master is how...

Install phpMyAdmin on Rocky Linux 9

How To Install phpMyAdmin on Rocky Linux 9

by samm
November 11, 2023
0

If you're navigating the world of Rocky Linux 9 and looking to streamline your MariaDB or MySQL database management, installing...

Logrotate In Linux

How To Manage Log Files Using Logrotate In Linux

by samm
November 10, 2023
0

Log files are an essential part of any Linux system. They provide valuable insights into the system's activities, helping administrators...

Load More

RECOMMENDED.

Install Redis on Debian

How To Install Redis on Debian 11 Server

October 16, 2023
Secure SSH with Fail2Ban

How To Secure SSH with Fail2Ban on Rocky Linux 9

October 29, 2023
sammlinux sammlinux sammlinux

Related Posts

Install and Secure phpMyAdmin on Ubuntu 22.04
Ubuntu

How To Install and Secure phpMyAdmin on Ubuntu 22.04

July 22, 2024
Secure SSH with Fail2Ban
Ubuntu

How To Secure SSH with Fail2Ban on Ubuntu 22.04

October 29, 2023
Install Uptime Kuma on Ubuntu 22.04
Ubuntu

How To Install Uptime Kuma on Ubuntu 22.04

November 12, 2023
Install Ubuntu Server 22.04
Ubuntu

How To Install Ubuntu Server 22.04 LTS with Screenshots

October 21, 2023
Load More
Next Post
Install Composer in Ubuntu

How To Install Composer in Ubuntu 22.04: A Comprehensive Guide

  • About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap

© 2023 sammlinux - Learn Today for Lead Tomorrow.

No Result
View All Result
  • Ubuntu
  • Debian
  • Rocky Linux
  • CentOS
  • Linux

© 2023 sammlinux - Learn Today for Lead Tomorrow.