go env -w GOPROXY=https://goproxy.cn,https://mirrors.aliyun.com/goproxy,https://goproxy.io,direct

go mod 有以下命令:

命令说明
downloaddownload modules to local cache(下载依赖包)
editedit go.mod from tools or scripts(编辑go.mod)
graphprint module requirement graph (打印模块依赖图)
initinitialize new module in current directory(在当前目录初始化mod)
tidyadd missing and remove unused modules(拉取缺少的模块,移除不用的模块)
vendormake vendored copy of dependencies(将依赖复制到vendor下)
verifyverify 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