简体   繁体   English

go get -u 模块不适用于私有存储库,但 go get 工作

[英]go get -u with modules not working with private repos but go get works

I'm trying to convert to use go modules in my repo now, but it keeps failing with exit 128. Repository not found The requested repository does not exist, or you do not have permission to access it.我现在正在尝试在我的存储库中转换为使用 go 模块,但它一直失败并退出 128。未找到存储库 请求的存储库不存在,或者您无权访问它。 fatal: Could not read from remote repository.致命:无法从远程存储库读取。

Please make sure you have the correct access rights and the repository exists.请确保您拥有正确的访问权限并且存储库存在。

My repos are private repos and i have git configured to use ssh insteadOf https when I run go get ./... with NO modules GO111MODULE=off I'm able to get the repos.我的存储库是私有存储库,当我运行go get ./...没有模块 GO111MODULE=off 我能够获得存储库时,我将 git 配置为使用 ssh 而不是 https。

However, when I switch to modules on GO111MODULE=on I get the error mentioned above.但是,当我在GO111MODULE=on切换到模块时,出现上述错误。 My current go vars are我目前的 go vars 是

GO111MODULE=on
GOPROXY=direct
GOSUMDB=off

I've read the articles like this and this to setup git url insteadOf.我已经阅读了像这样这样的文章来设置 git url 代替。

and here is my git setting这是我的 git 设置

[url "ssh://git@git.company.com:port"]
    insteadOf = https://git.company.com

Ideas?想法?

Thanks谢谢

On newer version of Golang, you must specify the repository private on your golang environment because the private repository can't do checksum.在较新版本的 Golang 上,您必须在 golang 环境中指定私有存储库,因为私有存储库无法进行校验和。 So for the solution is like below :所以解决方案如下:

go env -w GOPRIVATE=github.com/username/*

or或者

export GOPRIVATE="github.com/username/*"

replace github.com which your version control like bitbucket, etc. And replace username with your username or your company.将 github.com 替换为您的版本控制(如 bitbucket 等)。并将username替换为您的用户名或您的公司。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM