我正在尝试构建一个使用私有的git存储库的go应用程序。我的github帐户有一个ssh密钥,并且.gitconfig文件中包含以下内容:
[url "https://username:[email protected]"]
insteadOf = https://github.com
[url "ssh://[email protected]/"]
insteadOf = https://github.com/
当我执行go test或go build时,系统会要求我输入密码。然后我得到回应:
go: found github.com/x/businesses in github.com/x/businesses v0.0.0-yy
go: cmd/main/cmd imports
github.com/x/businesses: github.com/x/[email protected]/go.mod:
verifying module: github.com/x/[email protected]/go.mod:
reading https://sum.golang.org/lookup/github.com/xx/[email protected]: 410 Gone
server response:
not found: github.com/x/[email protected]:
invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/*
in tmp/gopath/pkg/mod/cache/vcs/zz:
exit status 128:
fatal: could not read Username for 'https://github.com': terminal prompts disabled
我试着删除.gitconfig中的top代替而不是其他原因,然后尝试尝试。
您的git配置应该看起来像 [url "[email protected]:"] insteadOf = https://github.com/
您所拥有的。
然后,您可以通过Go
使用如下所示的私人存储库来告诉您:GOPRIVATE="github.com/your_username_or_org" go get github.com/name_or_org/repo_name
另外,我通常不在我的SSH密钥上放置密码,因为每次都键入该密码有点烦人,但通过添加它当然更安全,就像评论中指出的那样。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句