How to Install Golang on Fedora 40/39 Linux

Looking to install Golang on Fedora 40 or 39 Linux? Golang, or Go, is a modern, open-source programming language renowned for its efficiency and performance in application development. With its straightforward design, Go is an excellent choice for developers seeking to build scalable and robust software.

Golang stands out for several reasons:

  • Simplicity: Clean and straightforward syntax, making it accessible for both newcomers and experienced programmers.
  • Performance: Compiled into machine code, ensuring fast execution and handling of demanding tasks.
  • Concurrency: Built-in support for concurrent programming, allowing multiple operations to run simultaneously.
  • Memory Management: Automatic garbage collection prevents memory leaks, enhancing application stability.
  • Type Safety: Statically typed, catching more errors at compile time for more reliable code.
  • Rapid Compilation: Quick compile times keep development agile and responsive to changes.

With the introduction out of the way, let’s explore how to install Golang on Fedora 40 or 39 using terminal commands and various methods.

Step 1: Update Fedora Before Golang Installation

Before installing Golang, updating your Fedora Linux operating system is recommended. This will ensure you have the latest version of the operating system and all its dependencies. To update Fedora, run the following command in the terminal or command-line interface:

sudo dnf upgrade --refresh

Step 2: Install Golang via the DNF command

DNF, which stands for Dandified YUM, is a package manager for Fedora Linux that you can use to install Golang on Fedora Linux. To install Golang using DNF, run the following command:

sudo dnf install golang

To verify that Golang has been installed successfully, run the following command:

go version

Step 3: Create a Golang Test Application

Now that Golang is installed on your Fedora Linux operating system, it’s time to create a small program to test if everything works as expected. This section will create a “Hello World” program in Golang.

Create a directory for the program using the following command:

mkdir go-hello

Create a .go file using the nano editor:

nano go-hello/hello.go

Add the following text to create the “Hello World” program:

package main

import "fmt"

func main() {
     fmt.Printf("Hello, World from LinuxCapable.com\n") 
}

Create a go.mod file by running the following command:

nano go-hello/go.mod

Add the following line to the go.mod file:

module example.com/mod

Save the file (CTRL+O), then exit (CTRL+X).

Change the directory to the go-hello directory and build the program by running the following command:

cd go-hello && go build

Finally, execute the “Hello World” program by running the following command:

./mod

Conclusion

This guide offers an in-depth guide on installing Golang on Fedora Linux. Golang’s popularity is on the rise as more developers recognize its capabilities. With its robust features and efficient performance, Golang is well-suited for web development, system programming, and network programming. If you want to learn this versatile language, numerous online resources are available to help you get started.

For more information on how to use and develop Go, visit the official documentation.

Leave a Comment