How to Install Go on CentOS 8

How to Install Go on CentOS 8

How to Install Go on CentOS 8

We hope this post helped you to find out  How to Install Go on CentOS 8

Go, sometimes called golang is a contemporary open-source programming language created by Google that means that you can construct dependable and environment friendly functions.

Many common functions, equivalent to Kubernetes, Docker, Prometheus, and Terraform, are written in Go.

This tutorial explains find out how to obtain and set up Go on CentOS 8.

Downloading and installing in Go on CentOS 8 #

On the time of writing this text, the newest steady model of Go is model 1.13.4. Earlier than downloading the tarball, go to the official Go downloads page and test if there’s a new model obtainable.

Carry out the next steps beneath to obtain and set up Go on CentOS 8:

Step 1. Obtain the Go binary utilizing both the wget or curl utility:


Step 2. Once the archive is downloaded, verify the tarball checksum by typing:

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

Step 3. Make sure the hash printed from the sha256sum command matches the one from the downloads page.

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

Step 4. Extract the tarball to the /usr/local directory using the tar command:

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

The command above must be run as root or a user with sudo privileges.

Step 5. Tell the system where to find the Go executable binaries by adjusting the $PATH environment variable.

You can do this by adding the following line to the /etc/profile file (for a system-wide installation) or to the $HOME/.bash_profile file (for a current user installation):

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

Save the file, and load the new PATH environment variable into the current shell session using the source command:

 source ~/.bash_profile

That’s it. At this point, Go has been installed on your CentOS system.

Step 6. Test the Installation #

To test whether Go is installed correctly, we will set up a workspace and build a simple “Hello world” program.

Step 7. The location of the workspace directory is specified with the GOPATH environment variable. By default, it is set to $HOME/go. To create the directory run the following command:

mkdir ~/go

Step 8. Inside the workspace create a new directory src/hello:

mkdir -p ~/go/src/hello 

In that directory create a file named hello.go:

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

Paste the following code to the file:

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

Step 9. Navigate to the ~/go/src/hello directory and run go build to build the code:

 cd ~/go/src/hello
go build

The command above will build an executable named hello.

Run the executable by typing: ./hello If you see the following output, then you have successfully installed Go. Hello, World

Conclusion #

Now that you’ve got downloaded and put in Go, you can begin writing your Go code.

We hope the How to Install Go on CentOS 8 help you. If you have any query regarding How to Install Go on CentOS 8 drop a comment below and we will get back to you at the earliest.

We hope this post helped you to find out  How to Install Go on CentOS 8  . You may also want to see – How to Install Anaconda on CentOS 8

Share via
Copy link
Powered by Social Snap