How to Install GoLang on Fedora 36 / Fedora 35

GoLang is an open-source programming language developed at Google by its engineers in 2009. Go language is similar to C, but with garbage collection, memory safety, and structural typing. It is most widely used for microservices these days.

Here, we will see how to install GoLang on Fedora 36 / Fedora 35.

Install GoLang On Fedora 36

Before installing the Go Lang, update your system with the latest security patches to ensure the system is not vulnerable.

sudo dnf update -y

Then, reboot your system

And then, install the GoLang package with the dnf command.

sudo dnf install -y go

Verify GoLang Installation

After the package installation, run the below command to see the version of the Go language.

go version

Output:

go version go1.18.3 linux/amd64

You can also check the GoLang environment variables with the below command.

go env

Output:

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/fedora/.cache/go-build"
GOENV="/home/fedora/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/fedora/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/fedora/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/usr/lib/golang"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/golang/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3590682015=/tmp/go-build -gno-record-gcc-switches"

Create First GoLang Project

Assuming that you have a workspace called go in your $HOME directory. Otherwise, create a directory and go to the directory.

mkdir $HOME/go && cd $HOME/go

Let’s create a simple program to test the GoLang installation. To do that, create a project directory called hello under your workspace.

mkdir -p hello && cd hello

Then, create a file.

nano hello.go

Use the below content for the hello.go file.

package main

import "fmt"

func main() {
    fmt.Printf("Welcome To ITzGeek\n")
}

Now, compile it with the go command.

go run hello.go

You should get the following greeting text.

Welcome To ITzGeek

Conclusion

That’s all. You have successfully installed GoLang on Fedora 36 / Fedora 35.

fedora 35fedora 36golang
Comments (0)
Add Comment