golang is a programming language that is very popular for writing high-performance web applications and memory-intensive applications. Golang has obvious advantages over other programming languages in terms of concurrency performance and memory usage. This article will introduce how to install golang on CentOS system.
Before you start installing golang, you need to make sure that the following software packages are installed on your system.
You can use the following command to check whether these software are installed:
<code>which curl tar git</code>
If these software are already installed, return the path of the software. Otherwise, install them using the following command:
<code>yum update yum install curl tar git</code>
golang installation packages are stored in the official repository and can be downloaded from there using the curl command.
<code>curl -O https://dl.google.com/go/go1.15.7.linux-amd64.tar.gz</code>
This command will download the golang installation package. The download time depends on your Internet connection speed.
After the download is complete, use the following command to unzip:
<code>tar -xvf go1.15.7.linux-amd64.tar.gz</code>
This command will create a new file named go in the current directory Directory, which contains all files of golang.
In order to access golang through the command line, you need to add it to your PATH environment variable. The PATH environment variable contains the path where the system searches for executable files. In Linux, this environment variable is usually set to /usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/opt/X11/bin:/usr/games:/usr/local /games.
Use a text editor to open the /etc/profile file.
<code>nano /etc/profile</code>
Add the following at the end of the file:
<code>export PATH=$PATH:/usr/local/go/bin</code>
Save the file and close the text editor. Run the following command to make the changes take effect:
<code>source /etc/profile</code>
After completing the installation and configuration of golang, you can use the following command to verify whether golang is installed correctly:
<code>go version</code>
The output returned by this command should show the installed golang version.
In this article, we introduced how to install golang on CentOS. We downloaded the installation package of the golang program, unzipped it, and added it to the PATH environment variable. Finally, we verify whether the golang installation was successful by running the "go version" command.
The above is the detailed content of golang centos installation. For more information, please follow other related articles on the PHP Chinese website!