我想在另一个GoLang项目中使用托管在GitHub上的私有仓库。
我做了以下几步:
- 在我的GitHub帐户设置中创建了一个私人访问令牌
然后执行以下命令:
git config --global url."https://xxxxxx:ACCESS_TOKEN@github.com".insteadOf "https://github.com"
将“xxxxxx”替换为我的真实GitHub用户名,然后是适当的ACCESS_TOKEN。
go get github.com/private/repo
然而,我总是得到以下错误:
go: downloading github.com/xxxxxxxx/yyyyyyyyy-go-sdk v0.0.0-20200307154628-cbcb73911013
go get github.com/xxxxxxxx/yyyyyyyyy-go-sdk: github.com/xxxxxxxx/yyyyyyyyy-go-sdk@v0.0.0-20200307154628-cbcb73911013: verifying module: github.com/xxxxxxxx/yyyyyyyyy-go-sdk@v0.0.0-20200307154628-cbcb73911013: reading https://sum.golang.org/lookup/github.com/xxxxxxxx/yyyyyyyyy-go-sdk@v0.0.0-20200307154628-cbcb73911013: 410 Gone
server response:
not found: github.com/xxxxxxxx/yyyyyyyyy-go-sdk@v0.0.0-20200307154628-cbcb73911013: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /tmp/gopath/pkg/mod/cache/vcs/5eca4f397ed3a418f58ee864965ed24936e21268780304d6941f5b3983d31ad1: exit status 128:
fatal: could not read Username for 'https://github.com': terminal prompts disabled
我也尝试了以下方法:
GONOSUMDB=github.com/myusername go get github.com/xxxxxx/yyy...
根据 StackOverflow 上类似问题的一些答案,我尝试在 repo-url 后面添加 ".git"。但这根本行不通。
这可能是什么问题,我该如何解决?
版本:
♠ git --version
git version 2.25.0
hub version 2.14.2
♠ Go版本1.14
go env -w "GOPRIVATE=github.com/mycompany/*"
- Brian McKelvey