交叉编译windows的exe
export GOPROXY=https://proxy.golang.com.cn,direct
go mod tidy
必须写在一行
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build hello3.go
If you are experiencing issues with downloading packages from the official Go module proxy, you can try using an alternative proxy like goproxy.cn
. This is a popular Go module proxy server in China, which provides a mirror of the official Go module proxy server and can help to speed up the download process for Chinese developers.
To use goproxy.cn
, you can set the GOPROXY
environment variable to https://goproxy.cn
:
export GOPROXY=https://goproxy.cn
This will instruct the Go tool to use goproxy.cn
as the primary module proxy server for downloading packages.
You can also set this environment variable permanently in your shell profile file (e.g. .bashrc
, .zs