1)因为网速较慢导致的...

下面是我设置的hosts,各位童鞋可以用IP查找工具来获取IP地址设置hosts,速度1-2分钟可以下载结束。

在host 文件中设置:

 192.30.253.112 github.com
 151.101.185.194 github.global.ssl.fastly.net 即可。

如果142.251.42.241:443: connectex: A connection attempt failed .....  报错

设置代理: 

go env -w GOPROXY=https://goproxy.cn

同时:关掉GOSUMDB   go env -w GOSUMDB=off

如果是以下报错:配置git

error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
package github.com/beego/bee: exit status 128

git config --global http.sslVerify false

再不行就是公司内部网络的防火墙问题,切换网络或者换手机的热点。 

(2)但是上述方案还是没有解决问题,仔细阅读文档:

The GOPROXY environment variable may now be set to a comma-separated list of proxy URLs or the special token direct, and its default value is now https://proxy.golang.org,direct. When resolving a package path to its containing module, the go command will try all candidate module paths on each proxy in the list in succession. An unreachable proxy or HTTP status code other than 404 or 410 terminates the search without consulting the remaining proxies.

也就是上面的代理地址变换了

那么我们改成这样:

go env -w GOPROXY=https://goproxy.org,direct

同时go env -w GO111MODULE="on" 问题即可解决!

(3)报错继续...

#### 还是继续 unrecognized import path "google.golang.org/protobuf/proto": https fetch: Get "https://google.golang.org/protobuf/proto?go-get=1":

找到你的GOPATH/src目录,新建google.golang.org文件夹

在google.golang.org目录下执行

git clone https://e.coding.net/robinqiwei/googleprotobuf.git protobuf

Linux下使用方法如下:

mkdir -p $GOPATH/src/google.golang.org
git clone https://e.coding.net/robinqiwei/googleprotobuf.git $GOPATH/src/google.golang.org/protobuf

#### 还是继续 unrecognized import path "golang.org/x/sys/windows": https fetch: Get "https://golang.org/x/sys/windows?go-get=1": 

在$GOPATH/src/ 下创建 golang.org/x文件夹,然后到golang.org/x

git clone https://github.com/golang/sync.git
git clone https://github.com/golang/crypto.git
git clone https://github.com/golang/sys.git

 ####还是继续 unrecognized import path "golang.org/x/tools/go/packages": https fetch: Get "https://golang.org/x/tools/go/packages?go-get=1":

执行git clone https://github.com/golang/tools.git

####还是继续  unrecognized import path "golang.org/x/mod/semver": https fetch: Get "https://golang.org/x/mod/semver?go-get=1"

打开https://github.com/golang地址将必要的mod,text,net等子项库都下载下来。

####还是继续cannot find package "github.com/hashicorp/hcl/hcl/printer" in any of:

出现 cannot find package "github.com/hashicorp/hcl/hcl/printer" in any of: 等类似github地址找不到的情况,将报错信息中的地址拿出来后发现无法找到页面 =>404

我们尝试将链接逐级减少后发现 github.com/hashicorp/hcl 是可以拿到页面的,执行

go get -u github.com/hashicorp/hcl 但是该版本里面均没有printer文件夹,只有最初的v1.0.0版本,所以需要github.com/hashicorp 下面执行

git clone -b v1.0.0 --depth=1 https://github.com/hashicorp/hcl.git

####继续报错go\src\github.com\prometheus\common\expfmt\decode.go:89:38: cannot use v :

Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐