Golang- environment to build
Download and install the official guide Golang
http://docs.studygolang.com/doc/install
1.Windows
OS: Windows 10 x64 Professional Edition
Golang: go1.14.1.windows-amd64.msi
1. Download
https://studygolang.com/dl
go1.14.1.windows-amd64.msi download link
https://dl.google.com/go/go1.14.1.windows-amd64.msi
2. Install
Double-installed go1.14.1.windows-amd64.msi
3. Environment Variables
After installation is complete configuration environment variable
This [computer] right click -> Properties -> Advanced System Settings -> Advanced -> Environment Variables -> System Variables -> New
Environment variable name Explanation Examples GOROOT Golang 1.14.1 mounting position D:\Program Files\Go Gofatः Golang coding directory ( containing src [source projects] / pkg [dependencies] / bin [executable] three directories directory ) D:\ProgramData\Workspace\Go GOBIN Binary executable directory % GOPATH% \ bin GO111MODULE on / auto / off on GOPROXY Agent (in particular especially important after GO111MODULE configured on or auto) https://goproxy.io Path Windows executable files directory, you need appends% GOROOT% \ bin;% GOPATH% \ bin;% GOBIN%; ;%GOROOT%\bin;%GOPATH%\bin;%GOBIN%;
First delete user variables in the environment variable GOPATH set system environment variables (default go installation time) after
all the environment variables configured, must save OK
4. Test
1. Open the DOS command terminal
Win + R input cmd, carriage
2. Enter go envgo env
Consistent with the content item the following configuration and configuration environment variable is the emergence of OK!
3. View version
go version
4. Helpgo help
2.Linux
1.CentOS
OS: Linux CentOS release 07/07/1908 (Core)
Golang: go1.14.1.linux-amd64.tar.gz
1. Download
1. Install wget download tool
yum -y install wget
2. Go to the home directory of the user admincd /home/admin/
3. Download-amd64.tar.gz go1.14.1.linux
go1.14.1.linux-amd64.tar.gz of Downloadhttps://studygolang.com/dl/golang/go1.14.1.linux-amd64.tar.gz
Download Command
wget https://studygolang.com/dl/golang/go1.14.1.linux-amd64.tar.gz
2. Extract
1. extracted to / usr / local / directory
tar -zxvf /home/admin/go1.14.1.linux-amd64.tar.gz -C /usr/local/
2. Go to the / usr / local / go down to see if there is a directory
cd /usr/local/ ls
3. Environment Variables
1. Set working directory (pkg / bin / src three directories)
mkdir -p /home/admin/workspace/go/pkg /home/admin/workspace/go/bin /home/admin/workspace/go/src
2. Install the vim
yum -y install vim
3. Set Environment Variables
vim /etc/profile
At the end of [uppercase keyboard press reaches the end of line G]
is added the following:export GOROOT=/usr/local/go export GOPATH=/home/admin/workspace/go export GOBIN=/home/admin/workspace/go/bin export GO111MODULE="on" export GOPROXY=https://goproxy.io export PATH=$PATH:$GOROOT/bin:$GOPATH/bin:$GOBIN:$GOPROXY
Save and exit [esc ->: wq]4. validate the configuration
source /etc/profile
4. Test
1. Enter go env
go env
Consistent with the content item the following configuration and configuration environment variable is the emergence of OK! >
2. Enter the go version View versiongo version
2.Ubuntu
OS: Ubuntu 18.04.4 LTS
Golang: go1.14.1.linux-amd64.tar.gz
1. Download
1. Install wget download tool
sudo apt-get install -y wget
2. Go to the home directory of the user golangcd /home/golang/
3. Download-amd64.tar.gz go1.14.1.linux
go1.14.1.linux-amd64.tar.gz of Downloadhttps://studygolang.com/dl/golang/go1.14.1.linux-amd64.tar.gz
Download Command
wget https://studygolang.com/dl/golang/go1.14.1.linux-amd64.tar.gz
2. Extract
1. extracted to / usr / local / directory
sudo tar -zxvf /home/golang/go1.14.1.linux-amd64.tar.gz -C /usr/local/
2. Go to the / usr / local / go down to see if there is a directory
cd /usr/local/ ls
3. Environment Variables
1. Set working directory (pkg / bin / src three directories)
sudo mkdir -p /home/golang/workspace/go/pkg /home/golang/workspace/go/bin /home/golang/workspace/go/src
2. Install the vim
sudo apt-get install -y vim
3. Set Environment Variables
sudo vim /etc/profile
At the end of [uppercase keyboard press reaches the end of line G]
is added the following:export GOROOT=/usr/local/go export GOPATH=/home/golang/workspace/go export GOBIN=/home/golang/workspace/go/bin export GO111MODULE="on" export GOPROXY=https://goproxy.io export PATH=$PATH:$GOROOT/bin:$GOPATH/bin:$GOBIN:$GOPROXY
Save and exit [esc ->: wq]4. validate the configuration
source /etc/profile
4. Test
1. Enter go env
go env
Consistent with the content item the following configuration and configuration environment variable is the emergence of OK! >
2. Enter the go version View versiongo version