Home > Article > Backend Development > How to install golang with curl
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:
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!