1 Download the installation package from the official website
golang.google.cn/dl/
Foolproof operation click to complete installation
The installation package is installed in /usr/local by default
2 Configure the environment variable GOPATH
Enter vi ~/. Bash_profile and select e to open the configuration file
Press the keyboard I to enter inset editing mode
Add the environment variable to it
export GOROOT=/usr/local/go
Press Esc to exit editing mode
Press: wq! End Editing and save
Run the source ~/. Bash_profile command to restart the terminal for the environment variables to take effect