How to Install Golang on CentOS

Go or Golang is an open-source programming language that is widely used for building high-performance and scalable applications. It was developed by Google and is known for its simplicity, efficiency, and concurrency features. In this guide, we will show you how to install Golang on CentOS.

Step 1: Update the System:

The first step is to update the system to ensure that all packages are up to date. Run the following command:

sudo yum update -y

This will update all the installed packages on your CentOS system.

Step 2: Download Golang:

Next, download the Golang package from the official website. You can use the wget command to download the package:

sudo wget https://golang.org/dl/go1.16.3.linux-amd64.tar.gz

This command will download the Golang package to the current working directory.

See also  How to Add Webtatic Repository on CentOS 6.3

Step 3: Extract Golang:

After downloading the package, extract it using the following command:

sudo tar -xvf go1.16.3.linux-amd64.tar.gz

This will extract the Golang package to the /usr/local directory.

Step 4: Set Environment Variables:

To use Golang, you need to set some environment variables. Open the /etc/profile file using any text editor and add the following lines at the end of the file:

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

Save and close the file. Then, load the profile file to apply the changes:

source /etc/profile

Step 5: Verify Installation:

Finally, verify the Golang installation by running the following command:

go version

If Golang is installed properly, it will show the version number.

Commands Mentioned:

  • sudo yum update -y – Updates all the installed packages on CentOS.
  • sudo wget https://golang.org/dl/go1.16.3.linux-amd64.tar.gz – Downloads the Golang package from the official website.
  • sudo tar -xvf go1.16.3.linux-amd64.tar.gz – Extracts the Golang package to the /usr/local directory.
  • export PATH=$PATH:/usr/local/go/bin – Sets the Golang binary path.
  • export GOPATH=$HOME/go – Sets the location of the Go workspace.
  • export PATH=$PATH:$GOPATH/bin – Adds the GOPATH/bin directory to the PATH.
  • source /etc/profile – Loads the profile file to apply the changes.
  • go version – Verifies the Golang installation.
See also  How to Install and Use Traceroute in Linux RHEL 6/7, CentOS 6/7, Oracle Linux 6/7

Conclusion:

In this guide, we have shown you how to install Golang on CentOS. We started by updating the system, downloading the Golang package, and extracting it to the /usr/local directory. Then, we set the environment variables to use Golang and verified the installation. By following these steps, you should now have Golang installed and ready to use for building high-performance and scalable applications. Golang is a popular programming language for developers because of its simple syntax, powerful tools, and community-driven development.

See also  How to Fix "-bash: man: command not found" on CentOS 6.3

Installing Golang on CentOS is a straightforward process that involves downloading the package from the official website, extracting it to the system, setting environment variables, and verifying the installation. By following the steps outlined in this guide, you should now have Golang installed on your CentOS system.

In conclusion, Golang is an excellent programming language for building high-performance and scalable applications. By installing Golang on CentOS, you can take advantage of its powerful features and tools. If you encounter any issues during the installation process, feel free to leave a comment or suggest improvements to this guide.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *