How to install golang with curl

PHPz
Release: 2023-04-23 13:51:15
Original
563 people have browsed it

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

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

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

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

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

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

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

source ~/.bashrc
Copy after login

Step 4 - Verify installation

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

go version
Copy after login

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

go version go1.16.3 linux/amd64
Copy after login

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!

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!