Announcement

Collapse
No announcement yet.

How to Install Go on Ubuntu 24.04

Collapse
X
Collapse
  •  

  • How to Install Go on Ubuntu 24.04


    Golang (Go) is a programming language provided by Google to help developers create scalable and secure systems. Its simplicity makes any developer want to learn the language and use it quickly.

    While Go is a go-to programming language for many developers, you must first install it on Ubuntu 24.04 before you begin using it for your development. We’ve covered three installation methods that anyone can use. Read on!

    Three Methods of Installing Go on Ubuntu 24.04

    The Go programming language has numerous applications, and as a Ubuntu user, you have three methods for installing Go. You can source it from the snap store or install it from the Ubuntu repository using APT. Still, you can download the Go tarball, extract it, and add its path to make it accessible on your system. All these methods are discussed below.

    Method 1: Install Go on Ubuntu 24.04 Via APT

    The first step in this method is to update the Ubuntu 24.04 repository. The Go version installed with this method is stable but not always the latest available version.

    Let’s first update the system.

    $ sudo apt update




    Next, use APT to install the Go package.

    $ sudo apt install golang-go




    Once the installation process is completed, view the installed Golang version.

    $ go version




    Method 2: Install Go Via Snap

    Even on Ubuntu 24.04 (Noble Numbat), you can access the Snap Store and install Snap packages. Go is available as a Snap package, and installing it via this approach will install even its dependencies.

    Here, you only need to execute the below command.

    $ sudo snap install go --classic




    Similarly, we can check the installed Go version.

    $ go version




    Notice how the two methods install the same Go version, which is the latest version when writing this post.

    Method 3: Install Go Via Its Official Repository

    The official way of installing Go on any Linux distribution is by sourcing its binary package. However, this is a long method as more steps are involved, but if you want the latest version or a specific Go version, this method is the best.

    The first step is to update the system.

    $ sudo apt update




    Next, visit the Go download page and find the version you want to install. Ensure you select the appropriate architecture for compatibility. We’ve chosen version 1.22.2 for this example.

    Once you’ve selected it, download the tarball using any utility. We’ve used wget for our example.

    $ wget https://go.dev/dl/go1.22.2.linux-amd64.tar.gz




    Allow the download to complete. The next step involves extracting the archive file. We’ve extracted it to the /usr/local/ directory using the tar command below.

    $ sudo tar -C /usr/local -xzf go1.20.1.linux-amd64.tar.gz

    $ ls /usr/local/go


    We’ve also run the ls command to confirm that the file was successfully unzipped and the new uncompressed Go folder containing all the required files exist.



    So far, we have the Go folder on our system, but we must add its binary to the path environment variable before we start using Go system-wide. Using a text editor, we will edit our bashrc to add the Go binary.

    Let’s open the file using the nano text editor.

    $ nano ~/.bashrc


    Next, paste the below line inside the file.

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




    Save the changes and exit the file. Also, source the file for the changes to apply.

    $ source ~/.bashrc




    Lastly, check the installed version.

    $ go version




    Test the Go Language

    Now that we’ve installed the Go programming language, we can use it for our development. Let’s create a simple ‘hello’ program to test that Go works correctly. Save it with a .go extension.



    Save the file and run it using the below syntax.

    $ go run program_name




    That’s it! The output confirms that Go is successfully installed on Ubuntu 24.04.

    Conclusion

    Go is a recent programming language developed by Google. Ubuntu supports Go and there are three ways you can install it. You can install it via APT or snap. Moreover, you can install it by downloading its official repository and adding its binary to your environment variable. Have fun using Go on Ubuntu 24.04.





    More...
      Posting comments is disabled.

    Categories

    Collapse

    Article Tags

    Collapse

    There are no tags yet.

    Latest Articles

    Collapse

    • What is Shebang: Bash Script Header on First Line?
      by Kasimba
      As Linux enthusiasts, we all come across bash scripting as an essential part of the Linux system. However, many Linux users don’t know why the first line of the bash script contains #!. So this combination of # and ! is called shebang or shebang.
      Although shebang looks like a bash script header, it initially instructs the system about interpreters to execute the script. This concept feels a bit complicated, but that’s not true, as this guide is all about the shebang: bash script header....
      Yesterday, 07:59 PM
    • Bash Script Loops Examples
      by Kasimba
      A loop in programming is a control structure that allows a specific code to be executed repeatedly until a condition is met. This process is repeated until no further action is required. Loop allows you to repeat the desired set of instructions numerous times to attain the desired outcome. These recursions can be useful for all tasks that require repetitive operations or when working with data collections.
      In this article, we will explore the meaning, types, and examples of loops, further...
      Yesterday, 07:59 PM
    • How to Install NVIDIA GPU Driver on Fedora 40+ KDE 6 Spin on Wayland
      by Kasimba
      Installing the NVIDIA GPU driver is the first thing you will want to do after installing Fedora 40 on your computer. Fedora 40 comes with different spins (desktop environments) and the latest software. Wayland display server (which will replace the X11/Xorg display server completely one day) is the default on some of the Fedora 40 spins. One of the most awaited Fedora 40 spin is the KDE spin. Fedora 40 KDE spin comes with the KDE Plasma 6 desktop environment which supports only the Wayland display...
      Yesterday, 07:59 PM
    • How to SSH Into Docker Container
      by Kasimba
      Administrators commonly use SSH to access and operate remote servers and devices, including a Docker container. When you connect to any device using SSH, you can run commands, access its files, and perform multiple other tasks. You can also use the Docker container as a hypervisor image that can run applications. For example, a software developer can create a Docker container image to package the software.

      Hence, a Docker container image package software with all the dependencies and...
      Yesterday, 01:12 PM
    • How to SSH Into EC2 Instance
      by Kasimba
      EC2 is a service provided by Amazon Web Services (AWS) that lets you rent virtual servers (known as instances). In these instances, you can leverage virtual machines to develop, test, deploy, and manage computer applications.

      SSH is an incredible utility for accessing and managing Amazon Elastic Compute Cloud (EC2) instances. With SSH, you can operate a remote device, access data, execute commands, troubleshoot issues, and more. Although you can easily SSH into an EC2 instance, many...
      Yesterday, 01:12 PM
    • How to Tunnel Web Traffic Through SSH for Secure Browsing
      by Kasimba
      Nowadays, an uncountable number of cyber attacks, scams, and data theft occur every single day. This makes it necessary for users to look for ways to secure their data. After all, it is better to take precautions than to experience a guilt trip. Fortunately, SSH offers tunneling, which channels internet traffic to your local system via a remote system.

      Meanwhile, this transmission encrypts incoming and outgoing network traffic on your local Linux device, ensuring the system’s security....
      Yesterday, 05:01 AM
    Working...
    X