Download the installation package
Preparation#
Download the compiler
Compiler download:
https://www.jetbrains.com.cn/go
Paid
vscode, vim
Free
1. Go Installation#
I will directly download the Go language installation package here,
Unzip to D:\software\go directory:
2. Environment Configuration#
The approximate location for configuring Windows system environment variables: Advanced system settings > Environment Variables > System Variables
Variable name: GO_HOME1231
Go package path:
D:\software\go\go1.23.1.windows
Click Path:
Add
%GO_HOME1231%\bin
Create Go third-party packages:
D:\software\go-third
D:\software\go-third\bin
D:\software\go-third\pkg
The meanings of the three directories under GOPATH are as follows:
The src directory mainly stores Go source files
The pkg directory stores compiled library files, mainly *.a files;
The bin directory mainly stores executable files
Variable name: GOPATH
Variable value: D:\software\go-third
Click Path:
Add
%GOPATH%\bin
GOPATH is the path for storing Go tool dependencies, you can set it yourself; I placed it in a directory created by GoWorks, which needs to include src, pkg, and bin three directories. Set to
Check if the installation was successful#
Check the version:
go version
Check the environment variables:
go env
Configure Go Proxy#
Add proxy in environment variables
GOPROXY
Variable name: GOPROXY
Variable value: https://goproxy.cn,direct
# Set goproxy.io proxy via command
go env -w GOPROXY="https://proxy.golang.com.cn,direct"
# Set GO111MODULE
go env -w GO111MODULE="on"
Purpose: Downloading foreign packages is relatively slow, using domestic proxies is faster
Common Go Proxies#
- goproxy https://goproxy.io/zh/
- Aliyun https://mirrors.aliyun.com/goproxy/
- Qiniu Cloud https://goproxy.cn
Other Operating Systems#
Configure Go proxy under mac/linux
# Configure GOPROXY environment variable
export GOPROXY=https://goproxy.io,direct
# You can also set private repositories or groups that do not go through the proxy, separated by commas (optional)
export GOPRIVATE=git.mycompany.com,github.com/my/private
Reference: https://goproxy.io/zh/