How to Install GoLang on Fedora 35 / Fedora 34

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 35 / Fedora 34.

Install GoLang On Fedora 35

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


go version go1.16.12 linux/amd64

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

go env 


GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/fedora/.cache/go-build" GOENV="/home/fedora/.config/go/env" GOEXE="" 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.16.12" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/dev/null" 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-build2226385121=/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.

vi hello.go

Use the below content for the hello.go file.

package main import "fmt" func main() { fmt.Printf("Welcome To ITzGeekn") }

Now, compile it with the go command.

go run hello.go

You should get the following greeting text.

Welcome To ITzGeek

Sumber: disini