8.8 C
Texas
angeloma
Senior Writer and partner

Install GO language on CentOS 7

Many people are passionate about programming and use Linux as a learning platform for it. In addition, Linux being a free system lends itself to this type of educational projects. However, although it is free, it does not leave aside security and stability, to be a whole software platform. In this sense, it also adapts to many programming languages that are emerging as an alternative to the existing ones that have dominated the sector for a long time as Java or C++. With this in mind, I will teach you how to install Go on CentOS7.

In the past, we’ve talked about GO. GO is a programming language that is becoming increasingly popular among developers and sysadmin. Initially, it was created by Google but has been expanding to be used by many current developers. It is inspired by C++ and has binaries for Windows, Linux and Mac OS. It is also open source under the BSD license.

1.- Upgrade the system

First of all, it is necessary to make a complete update to the system. For this, run the following command:

:~$ su
:~# yum update
- Advertisement -

1.- Upgrade the system
1.- Upgrade the system

The main objective of this is to make your system have the latest security patches available. This way it will be more stable and you will be ready to continue with the process.

2.- Download and install GO

CentOS 7 is a 64-bit system, so we will download the corresponding binaries using wget. If you do not have it installed, do it first.

:~# yum install wget
:~# wget https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz

2.- Download and install GO
2.- Download and install GO

At the time of writing this post, the latest stable version of GO is 1.11.5. Check the GO website for the latest version.

After doing this, it is necessary to unzip the downloaded folder. We will do it in the /usr/local directory.

:~# tar -zxvf go1.11.5.linux-amd64.tar.gz -C /usr/local

3.- Decompress GO
3.- Decompress GO

So that the installation does not have problems. It is necessary to define environment variables. I mean GOROOT and PATH.

:~# echo 'export GOROOT=/usr/local/go' | tee -a /etc/profile
:~# echo 'export PATH=$PATH:/usr/local/go/bin' | tee -a /etc/profile

Finally, refresh your bash profile.

:~# source /etc/profile

4.- Setting the environment variables
4.- Setting the environment variables

So, test GO.

3.- Test the installation

To verify that the installation has been correct, it is first necessary to show the version of GO. To do it, run this command:

:~# go version
:~# go env

5.- Showing the GO version
5.- Showing the GO version

However, the best way to check if your GO is correctly installed is to make a program and run it.

First, create a folder where the program will be located.

:~# mkdir -p src/test
:~# cd src/test

6.- Creating the folder
6.- Creating the folder

Next, create the file. I will name it test.go.

:~# nano test.go

And add the following:

package main
import "fmt"
func main() {
    fmt.Printf("Hi, I am Angelo. Thanks for visit Osradar\n")
}

7.- Creating a new file to test GO
7.- Creating a new file to test GO

Finally, run the file.

:~# go run test.go

8.- GO is running properly
8.- GO is running properly

So, GO is ready for the action.

Conclusion

Learning to program using GO is a good idea these days. The project is quite mature and more and more people are interested in this language. Installing GO on CentOS 7 is not complicated at all.

Please share this post with your friends.

- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

LEAVE A REPLY

Please enter your comment!
Please enter your name here



Latest article