golang centos installation

PHPz
Release: 2023-04-23 10:07:39
Original
156 people have browsed it

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.

  1. Prerequisites

Before you start installing golang, you need to make sure that the following software packages are installed on your system.

  • #curl
  • tar
  • git

You can use the following command to check whether these software are installed:

<code>which curl tar git</code>
Copy after login

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>
Copy after login
  1. Download golang

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>
Copy after login

This command will download the golang installation package. The download time depends on your Internet connection speed.

  1. Install golang

After the download is complete, use the following command to unzip:

<code>tar -xvf go1.15.7.linux-amd64.tar.gz</code>
Copy after login

This command will create a new file named go in the current directory Directory, which contains all files of golang.

  1. Configure environment variables

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>
Copy after login

Add the following at the end of the file:

<code>export PATH=$PATH:/usr/local/go/bin</code>
Copy after login

Save the file and close the text editor. Run the following command to make the changes take effect:

<code>source /etc/profile</code>
Copy after login
  1. Verify installation

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>
Copy after login

The output returned by this command should show the installed golang version.

  1. Summary

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!