简体   繁体   中英

go get url from github on my Apple MAC is not working on a private repository in company

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.

I think your question is kind duplicated. Try reading this and setting up your environment.

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

'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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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