YouTube Icon

Code Playground.

How to Install Go on CentOS 8

CFG

How to Install Go on CentOS 8

Go, frequently alluded to as golang is an advanced open-source programming language made by Google that permits you to fabricate dependable and proficient applications. 

Numerous well known applications, for example, Kubernetes, Docker, Prometheus, and Terraform, are written in Go. 

This instructional exercise discloses how to download and introduce Go on CentOS 8. 

Downloading and Installing Go on CentOS 8

At the hour of composing this article, the most recent stable rendition of Go is variant 1.13.4. Before downloading the tarball, visit the authority Go downloads page and check if there is another adaptation accessible. 

Play out the accompanying strides beneath to download and introduce Go on CentOS 8: 

Download the Go twofold utilizing either the wget or twist utility: 

wget https://dl.google.com/go/go1.13.4.linux-amd64.tar.gz

When the document is downloaded, confirm the tarball checksum by composing: 

sha256sum go1.13.4.linux-amd64.tar.gz

Ensure the hash printed from the sha256sum order coordinates the one from the downloads page. 

692d17071736f74be04a72a06dab9cac1cd759377bd85316e52b2227604c004c  go1.13.4.linux-amd64.tar.gz

Concentrate the tarball to the/usr/neighborhood catalog utilizing the tar order: 

sudo tar -C /usr/local -xf go1.13.4.linux-amd64.tar.gz

The order above must be run as root or a client with sudo benefits . 

Advise the framework where to discover the Go executable pairs by modifying the $PATH climate variable. 

You can do this by adding the accompanying line to the/and so forth/profile document (for a framework wide establishment) or to the $HOME/.bash_profile record (for a current client establishment): 

~/.bash_profile

export PATH=$PATH:/usr/local/go/bin

Spare the record, and burden the new PATH climate variable into the current shell meeting utilizing the source order: 

source ~/.bash_profile

That is it. Now, Go has been introduced on your CentOS framework. 

Test the Installation 

To test whether Go is introduced accurately, we will set up a workspace and construct a basic "Hi world" program. 

The area of the workspace catalog is determined with the GOPATH climate variable. Of course, it is set to $HOME/go. To make the registry run the accompanying order: 

mkdir ~/go

Inside the workspace make another registry src/hi: 

mkdir -p ~/go/src/hello

In that registry make a record named hello.go: 

nano ~/go/src/hello/hello.go

Glue the accompanying code to the record: 

~/go/src/hello/hello.go
package main

import "fmt"

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

Explore to the ~/go/src/hi registry and run go work to assemble the code: 

cd ~/go/src/hello
go build

The order above will fabricate an executable named hi. 

Run the executable by composing: 

./hello

On the off chance that you see the accompanying yield, at that point you have effectively introduced Go. 

Hello, World

Conclusion

Since you have downloaded and introduced Go, you can begin composing your Go code . 

In the event that you hit an issue or have criticism, leave a remark underneath.




CFG