2018-09-19 10:50
浏览 217

go get:Git设置被忽略

I try to go get a repository from a private gitlab server, from a mac.

I set the git config (~/.gitconfig) to use ssh instead of https :

[url ""]
    insteadOf =

When I clone the project using the https url, I get the correct replacement

$ git clone
$ cd project
$ git remote -v
origin (fetch)
origin (push)

However, when I use go get, it tries to use the https url, and fail

$ go get
package unrecognized import path "" (https fetch: Get x509: certificate signed by unknown authority)

Why is go get not using my git configuration ? How can I fix that ?

I know the problem is similar to this question : go get: Git settings ignored and many other question concerning private repos

my problem is different

图片转代码服务由CSDN问答提供 功能建议

我尝试从Mac的私有gitlab服务器获取存储库。 \ n

我将git config(〜/ .gitconfig)设置为使用ssh而不是https:

  [url“”] \  n代替Of =

当我使用https url克隆项目时,我得到了正确的替换 \ n

  $ git clone
$ cd project 
 $ git remote -v 
origin / project  (获取)
origin / project(推送)

但是,当我使用go get时,它将尝试使用https 网址,并且失败

package无法识别的导入路径“ gitlab.mysite”。  com / group / project”(https提取:获取由未知授权机构签名的证书)
   \  n 

为什么去不使用 ng我的git配置? 我该如何解决?


我的问题不同 >

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dougu3290 2018-09-19 13:42

    That error occurs before the git clone call. When you call go get, it makes an HTTPS call out to the URL to check the headers and see if it provides a go get redirect. That's what's failing.

    And it's failing because the certificate provided by the server isn't signed by a Certificate Authority that you have specified as trusted on your local system. This could be because your internal gitlab is using an unsigned certificate, because the CA used to sign it hasn't been added to your local system, or because your workplace is using a man-in-the-middle style proxy and you don't have that proxy's CA added. You can either attempt to fix the cert issue, or simply run:

    go get -insecure

    The -insecure flag permits fetching from repositories and resolving custom domains using insecure schemes such as HTTP. Use with caution.

    Notably, this bypasses the validation of the CA used to sign the server's certificate.

    打赏 评论

相关推荐 更多相似问题