Golang (also known as Go) is a programming language developed by Google, with powerful concurrency features and efficient compilation speed , deeply loved by developers. Installing the Golang environment is the first step to start learning and developing Go language projects. This article will introduce you to how to quickly install the Golang environment under different operating systems, and provide specific code examples to help you easily complete the installation process.
First, open the [Golang official website](https://golang.org/dl/) and find the appropriate Download the latest version of Golang installation package for Windows system.
Double-click the downloaded Golang installation package and follow the instructions of the installation wizard to complete the Golang installation.
Open the system's environment variable settings, create a new variable named GOROOT
in "System Variables", the value is Golang installation Path (e.g. C:Go
). Then add %GOROOT% in
path to the "Path" variable.
Enter the go version
command in the command prompt. If the Golang version information is successfully displayed, the installation is successful.
Enter the following command in the terminal to install Homebrew (you can skip this step if it is already installed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then use Homebrew to install Golang:
brew install golang
Open the terminal and edit the ~/.bash_profile
file (create it if it does not exist) , add the following content:
export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin
Save and execute the following command to make the configuration effective:
source ~/.bash_profile
Enter go version## in the terminal #Command, if the Golang version information is successfully displayed, the installation is successful.
sudo apt-get update sudo apt-get install golang
~/.profile file and add the following content:
export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin
source ~/.profile
go version command in the terminal. If the Golang version information is successfully displayed, the installation is successful.
The above is the detailed content of Complete with one click! Install Golang environment in five minutes. For more information, please follow other related articles on the PHP Chinese website!