由于众所周知的原因,在go工程里引用了墙外的包,导致无法下载所需要的第三方包:
go: google.golang.org/grpc@v1.21.0: unrecognized import path "google.golang.org/grpc" (https fetch: Get https://google.golang.org/grpc?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
go: google.golang.org/grpc@v1.19.0: unrecognized import path "google.golang.org/grpc" (https fetch: Get https://google.golang.org/grpc?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
go: finding github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af
go: golang.org/x/time@v0.0.0-20190308202827-9d24e82272b4: unrecognized import path "golang.org/x/time" (https fetch: Get https://golang.org/x/time?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
go: golang.org/x/sys@v0.0.0-20181107165924-66b7b1311ac8: 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/o timeout)
go: golang.org/x/tools@v0.0.0-20180221164845-07fd8470d635: unrecognized import path "golang.org/x/tools" (https fetch: Get https://golang.org/x/tools?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
go: google.golang.org/genproto@v0.0.0-20180817151627-c66870c02cf8: unrecognized import path "google.golang.org/genproto" (https fetch: Get https://google.golang.org/genproto?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
查了各种资料,有的要vpn,有的要手动下载对应的镜像包等等,但是感觉很麻烦,不简洁,对于后续升级也不方便,在本地开发环境操作还可以,但是在服务器部署就不容易了。
最后找的最简洁的方案(详情可以访问官网):
# 可以写入环境变量
export GOPROXY=https://goproxy.io
goland ide可以如下进行设置
有疑问加站长微信联系(非本文作者)