Atlantic.Net Blog

How to Install Golang on Fedora

Go is a high-level open-source programming language developed by Google. It is very similar to C and is used to build secure, scalable systems. It is a general-purpose language and is especially useful for distributed systems and cloud services. Go is known for its concurrency and ability to run multiple tasks simultaneously. If you are looking for solving complex computational problems, then Go is the best option for you.

In this post, we will show you how to install and use Golang on Fedora Linux.

Prerequisites

  • A server running Fedora 34 on the Atlantic.Net Cloud Platform
  • A root password is configured on your server

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Fedora 34 as the operating system with at least 2GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged in to your server, run the following command to update your base system with the latest available packages.

dnf update -y

Step 2 – Install Golang

By default, the Golang package is included in the Fedora default repo. You can install it using the following command.

dnf -y install go

Once Golang is installed, you can verify the Golang version using the following command.

go version

You will see the following output.

go version go1.16.15 linux/amd64

Step 3 – Create an Application with Golang

First, create an application directory using the following command.

mkdir go

Next, create another directory inside the Go directory.

cd go
mkdir -p src/helloworld 

Next, create a new application named helloworld.go.

cd src/helloworld
nano helloworld.go

Add the following code.

package main
import "fmt"
func main() {
	fmt.Printf("hello, world\n")
}

Save and close the file when you are done.

Step 4 – Run the Golang Application

Now, change the directory to helloworld and initialize the application using the following command.

cd /root/go/src/helloworld
go mod init

Next, build the application with the following command.

go build

Now, run your application using the following command.

./helloworld 

If everything is fine, you will see the following output.

hello, world

Conclusion

In this post, we showed you how to install Golang on Fedora Linux. You can now start building your own Golang application and hosted it in the production environment. You can now use Golang on dedicated server hosting from Atlantic.Net!

,

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year