Home >Backend Development >Golang >How to install golang with curl

How to install golang with curl

PHPz
PHPzOriginal
2023-04-23 10:08:11601browse

On Linux systems, we often need to install and use different software. Among these software, Go language (golang) has become increasingly popular because of its advantages such as efficient execution speed and high concurrency performance suitable for large-scale services. This article will introduce you how to install golang using curl tool on Linux system.

Prerequisites

Before you start installing golang, make sure your Linux system meets the following prerequisites:

  • 64-bit version of Linux system.
  • User account with administrator rights.
  • The curl tool has been installed. If it is not installed, please install it using the following command:
sudo apt-get install curl

How to install Golang

To install golang in Linux, you need to follow the steps below.

Step 1 - Download golang

First, you need to use the curl tool to download the latest version of golang. Visit the official website download page https://golang.org/dl/ and find the following content:

Linux
go1.16.3.linux-amd64.tar.gz

Right-click to copy the link address, and then use the curl tool to download golang:

curl -O https://golang.org/dl/go1.16.3.linux-amd64.tar.gz

Please note: Make sure you Downloading the latest version of golang. You need to replace the URL in the above command to match the current version you downloaded.

Step 2 - Install Golang

After the download is complete, extract the file to /usr/local:

sudo tar -xvf go1.16.3.linux-amd64.tar.gz -C /usr/local

Step 3 - Set environment variables

After successfully installing golang, you need to configure environment variables to use golang immediately. To do this, open the .bashrc file with the following command:

nano ~/.bashrc

Please add the following content at the end of the file:

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

Subsequently, immediately start the bashrc file with the following command:

source ~/.bashrc

Step 4 - Verify installation

After completing the above steps, use the following command to verify that golang has been successfully installed:

go version

If you see the following output, it means that golang has been successfully installed.

go version go1.16.3 linux/amd64

Conclusion

By using curl tool, we can install the latest version of golang on Linux system very easily. Additionally, we show you how to configure environment variables and verify golang installation. If you encounter any issues, please let us know in the comments.

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

Statement:
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