在我的苹果MAC上从github获取url并没有在公司的私人存储库中工作



我在苹果MAC笔记本电脑上,go get命令不起作用。我有正常的git访问权限,我可以git克隆、git提交和git推送。为什么这个去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.

这对我来说是有效的,基于@elulcao

go env -w GOPRIVATE=github.com/COMPANYNAME
git config --global --add url."git@github.com:".insteadOf "https://github.com/"

然后我可以做

go mod download

在项目git文件夹或go get

默认情况下,'go-get'不支持私有存储库。它只支持公开回购。

如果你想获得私人回购,请参考这个链接

最新更新