dongyuan1983 2018-09-19 10:50
浏览 238
已采纳

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 "git@gitlab.mysite.com:"]
    insteadOf = https://gitlab.mysite.com/

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

$ git clone https://gitlab.mysite.com/group/project
$ cd project
$ git remote -v
origin  git@gitlab.mysite.com:group/project (fetch)
origin  git@gitlab.mysite.com:group/project (push)

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

$ go get gitlab.mysite.com/group/project
package gitlab.mysite.com/group/project: unrecognized import path "gitlab.mysite.com/group/project" (https fetch: Get https://gitlab.mysite.com/group/project?go-get=1: 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

  • 写回答

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 gitlab.mysite.com/group/project
    

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊