在Linux上执行go build的时候,出现错误:
build helloweb: cannot load github.com/go-git/go-git/v5: module github.com/go-git/go-git/v5: Get https://proxy.golang.org/github.com/go-git/go-git/v5/@v/list: dial tcp 34.64.4.17:443: i/o timeout
查看go-git项目下的README.md文件,go-git下载方法:
The recommended way to install go-git is:
import "github.com/go-git/go-git/v5" // with go modules enabled (GO111MODULE=on or outside GOPATH)
import "github.com/go-git/go-git" // with go modules disabled
查看自己go环境:
go env
GO111MODULE=""
GOARCH="amd64"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
(我删了一部分)
发现自己的GO111MODULE=“”,跟官方提供的下载信息不对,因此:
export GO111MODULE = on
在运行go build,还是出现:
build helloweb: cannot load github.com/go-git/go-git/v5: module github.com/go-git/go-git/v5: Get https://proxy.golang.org/github.com/go-git/go-git/v5/@v/list: dial tcp 34.64.4.17:443: i/o timeout
网上查找go mod timeout的解决方法,发现https://proxy.golang.org被墙了,于是考虑换代理
export GOPROXY="https://goproxy.io"
运行go build成功
|
请发表评论