How to install golang on linux system

WBOY
Release: 2023-05-18 16:19:20
forward
1787 people have browsed it

Step 1: Download Golang

Please download the version corresponding to your system from the official website (https://golang.org/dl/) Adapted installation package. The latest version of Golang is currently version 1.17.

Here, we take the officially provided Linux version of Golang as an example. The command is as follows:

wget https://golang.org/dl/go1.17.linux-amd64.tar.gz
Copy after login

Step 2: Unzip the downloaded file

After the download is completed, we need to unzip the downloaded Golang installation package.

Use the following command to decompress:

tar -xvf go1.17.linux-amd64.tar.gz -C /usr/local/
Copy after login

After this step is completed, Golang will be decompressed into the /usr/local/go directory.

Step 3: Configure environment variables

Although Golang’s executable files can be automatically added to the PATH environment variable during the installation process, other configurations still need to be completed manually. Configuration of environment variables.

We need to add the following content to the ~/.bashrc or ~/.zshrc configuration file:

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

The meaning of the above configuration items is as follows:

  • export GOPATH=$HOME/go: This configuration specifies that Golang’s working directory is $HOME/go.

  • export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin: This configuration is to add Golang commands to the system commands path to use Golang tools directly in the terminal.

Step 4: Verify the installation

After the installation is completed, we should verify whether Golang was installed successfully. In the terminal, enter the following command to verify:

go version
Copy after login

If you see output similar to the following:

go version go1.17 linux/amd64
Copy after login

The above is the detailed content of How to install golang on linux system. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
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!