go env -w GOPROXY=https://goproxy.cn,https://mirrors.aliyun.com/goproxy,https://goproxy.io,direct
go mod 有以下命令:
命令 | 说明 |
download | download modules to local cache(下载依赖包) |
edit | edit go.mod from tools or scripts(编辑go.mod) |
graph | print module requirement graph (打印模块依赖图) |
init | initialize new module in current directory(在当前目录初始化mod) |
tidy | add missing and remove unused modules(拉取缺少的模块,移除不用的模块) |
vendor | make vendored copy of dependencies(将依赖复制到vendor下) |
verify | verify dependencies have expected content (验证依赖是否正确) |
why | explain why packages or modules are needed(解释为什么需要依赖) |
报错: require XXXX: version "v3.2.1" invalid: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v3
如果所依赖的包,没有提供这种依赖方式,可以指定依赖master的最新commit。
例如:
go get github.com/prometheus/prometheus@master