FedoraRHEL Based

How To Install GO on Fedora 40

Install GO on Fedora 40

In this tutorial, we will show you how to install GO on Fedora 40. GO, a statically typed programming language developed by Google has gained significant popularity among developers due to its simplicity, efficiency, and powerful concurrency features. When paired with Fedora 40, GO becomes an even more compelling choice for building high-performance and scalable applications.

One of the key advantages of using GO on Fedora 40 is its compatibility with the distribution’s infrastructure and system requirements. GO’s lightweight nature and minimal dependencies make it a perfect fit for Fedora 40’s streamlined architecture. The language’s built-in concurrency primitives, such as goroutines and channels, allow developers to write concurrent programs with ease, taking full advantage of Fedora 40’s multi-core processing capabilities.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Go programming language on Fedora 40.

Prerequisites

Before we dive into the installation process, ensure that you have the following prerequisites in place:

  • A server running one of the following operating systems: Fedora 40.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • You will need access to the terminal to execute commands. Fedora provides the Terminal application for this purpose. It can be found in your Applications menu.
  • A stable internet connection to download the necessary packages.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install GO on Fedora 40

Step 1. Update the System.

Before proceeding with the GO installation, it’s crucial to ensure that your Fedora 40 system is up to date and meets the necessary prerequisites. Start by running a system update to fetch the latest packages and security patches. Open a terminal and execute the following command:

sudo dnf clean all
sudo dnf update

This command will update your Fedora 40 system to the latest available versions of installed packages. Once the update process is complete, you can move on to the next step of installing GO.

Step 2. Installing Golang on Fedora 40.

Visit the official GO downloads page and download the latest stable version of GO for your Fedora 40 system. Choose the appropriate package based on your system architecture (32-bit or 64-bit):

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

Once the download is complete, open a terminal and navigate to the directory where the package was saved. Extract the contents of the package using the following command:

tar -xzf go1.22.2.linux-amd64.tar.gz

To install GO system-wide, move the extracted directory to the /usr/local directory using the following command:

sudo mv go /usr/local

To properly configure your GO installation, you need to set up the necessary environment variables. Open your shell’s configuration file (e.g., ~/.bashrc or ~/.zshrc) using a text editor:

nano ~/.bashrc

Add the following lines to the end of the file:

export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

For the changes to take effect, reload your shell’s configuration file using the following command:

source ~/.bashrc

To ensure that GO is installed correctly, run the following command in your terminal:

go version

If the installation was successful, you should see the version number of GO printed on the screen.

Step 3. Building Your First GO Project on Fedora 40

Now that your Fedora 40 system is set up for GO development, it’s time to create your first GO project. Let’s start with a classic “Hello, World!” program to test your setup:

mkdir hello-world
cd hello-world

In the project directory, initialize a new GO module using the following command:

go mod init hello-world

Create a new file named main.go in your project directory and open it in your preferred text editor. Add the following code to the file:

package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

Save the main.go file and run the following command in your terminal to execute the program:

go run main.go

If everything is set up correctly, you should see the message “Hello, World!” printed on the screen.

Congratulations! You have successfully installed Go. Thanks for using this tutorial for installing the Golang on the Fedora 40 system. For additional or useful information, we recommend you check the official Go programming language website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button