场景
使用go mod 编译时报错
go: golang.org/x/sys@v0.0.0-20180905080454-ebe1bf3edb33: unrecognized import path “golang.org/x/sys” (https fetch: Get https://golang.org/x/sys?go-get=1: dial tcp 216.239.37.1:443: i/otimeout)
go: golang.org/x/crypto@v0.0.0-20180904163835-0709b304e793: unrecognized import path “golang.org/x/crypto” (https fetch: Get https://golang.org/x/crypto?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
解决方案
- 设置代理
export GO111MODULE=on
export GOPROXY=https://goproxy.io
- 如果你用的Goland
GOland- Perferences - 搜索vgo- 填写代理地址 - 应用
解决