英文:
go get url from github on my Apple MAC is not working on a private repository in company
问题
我正在使用苹果MAC笔记本电脑,go get
命令无法工作。
我可以正常访问git,可以进行git克隆、git提交和git推送。为什么go get
命令不能工作?
temp % go get github.com/MYCOMPANY/myproject
go get: module github.com/MYCOMPANY/myproject: git ls-remote -q origin in /Users/someuser/go/pkg/mod/cache/vcs/1872293eea4df8de643499713e2d8621a72624bb2514a7a88c1182d1869ef891: exit status 128:
ssh: Could not resolve hostname github.com:MYCOMPANY: nodename nor servname provided, or not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
temp % go get github.com/MYCOMPANY/myproject
go get: module github.com/MYCOMPANY/myproject: git ls-remote -q origin in /Users/someuser/go/pkg/mod/cache/vcs/1872293eea4df8de643499713e2d8621a72624bb2514a7a88c1182d1869ef891: exit status 128:
ssh: Could not resolve hostname github.com:MYCOMPANY: nodename nor servname provided, or not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
这个错误提示表明在执行go get
命令时,无法解析主机名github.com:MYCOMPANY
。请确保你的网络连接正常,并且你有正确的访问权限以及仓库存在。
英文:
I'm on a Apple MAC Laptop, go get
command is not working.
I have normal git access, I can git clone and git commit and git push. Why does this go get command not work?
temp % go get github.com/MYCOMPANY/myproject
go get: module github.com/MYCOMPANY/myproject: git ls-remote -q origin in /Users/someuser/go/pkg/mod/cache/vcs/1872293eea4df8de643499713e2d8621a72624bb2514a7a88c1182d1869ef891: exit status 128:
ssh: Could not resolve hostname github.com:MYCOMPANY: nodename nor servname provided, or not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
temp % go get github.com/MYCOMPANY/myproject
go get: module github.com/MYCOMPANY/myproject: git ls-remote -q origin in /Users/someuser/go/pkg/mod/cache/vcs/1872293eea4df8de643499713e2d8621a72624bb2514a7a88c1182d1869ef891: exit status 128:
ssh: Could not resolve hostname github.com:MYCOMPANY: nodename nor servname provided, or not known
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
答案1
得分: 4
这是对我有效的方法,基于 @elulcao 的建议:
go env -w GOPRIVATE=github.com/COMPANYNAME
git config --global --add url."git@github.com:".insteadOf "https://github.com/"
然后我可以在项目的 git 文件夹中执行以下命令:
go mod download
或者使用 go get
命令。
英文:
This is what works for me, based on @elulcao
go env -w GOPRIVATE=github.com/COMPANYNAME
git config --global --add url."git@github.com:".insteadOf "https://github.com/"
Then I can do
go mod download
In the projects git folder or go get
答案2
得分: -1
“go get”默认不支持私有仓库,它只支持公共仓库。
如果你想获取私有仓库,请参考这个链接:link
英文:
'go get' by default does not support private repositories. It only supports public repos.
If you want to get private repos please refer to this link
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论