什么时候在使用 go 模块执行 `go build` 时会执行 `git ls-remote -q origin` ?
时间:2024-02-29
浏览:150
作者:佚名
编程并不是一个机械性的工作,而是需要有思考,有创新的工作,语法是固定的,但解决问题的思路则是依靠人的思维,这就需要我们坚持学习和更新自己的知识。今天golang学习网就整理分享《什么时候在使用 go 模块执行 `go build` 时会执行 `git ls-remote -q origin` ?》,文章讲解的知识点主要包括,如果你对Golang方面的知识点感兴趣,就不要错过golang学习网,在这可以对大家的知识积累有所帮助,助力开发能力的提升。
我的 gitlab 构建管道失败,因为它将运行 git ls-remote -q origin 指令,并报告错误“找不到您要查找的项目”。
[2022/01/04 15:58:00] /go/pkg/mod/***/finance/[email protected]/kafkax/kafka_consumer.go:9:2: reading golang.***.com/kit/swimlane/go.mod at revision v0.0.1: git ls-remote -q origin in /go/pkg/mod/cache/vcs/d59e078efe804645d7b0bc877750c96d810a57328e3acc47eb94bdb969209bf9: exit status 128: [2022/01/04 15:58:00] > gitlab: the project you were looking for could not be found. [2022/01/04 15:58:00] fatal: could not read from remote repository. [2022/01/04 15:58:00] [2022/01/04 15:58:00] please make sure you have the correct access rights [2022/01/04 15:58:00] and the repository exists.
实际上,“swimlane”依赖项(不是 go 模块项目)已经下载完毕。
[2022/01/04 15:57:39] go: downloading golang.***.com/kit/swimlane v0.0.1
[2022/01/04 15:57:39] get "golang.***.com/kit/swimlane": found meta tag vcs.metaimport{prefix:"golang.***.com/kit/swimlane", vcs:"git", reporoot:"git+ssh://git@git.***.com/kit/swimlane"} at //golang.***.com/kit/swimlane?go-get=1
但是,由于某种原因我没有弄清楚,似乎是“/kafkax/kafka_consumer.go:9:2”导致它运行“git ls-remote -q origin”来获取远程引用可用于“泳道”。
我使用 git ls-remote --get-url origin 来获取原始 url,即“http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@git.***.com/finance/order-center.吉特”。 “finance/order-center.git”正是 gitlab pipeline 构建失败的项目,但不是“swimlane”的起源。
我正在寻找一种使我的管道成功运行的方法。我们将非常感谢分享您对此问题的意见或解决方案。
谢谢!!!
附注原来的 git 配置是:
[2022/01/04 15:57:18] step 12/22 : run git config --list [2022/01/04 15:57:18] ---> running in 3170cf53e18e [2022/01/04 15:57:18] url.http://git.***.com/.insteadof=git+ssh://git@git.***.com/ [2022/01/04 15:57:18] fetch.recursesubmodules=false [2022/01/04 15:57:18] core.repositoryformatversion=0 [2022/01/04 15:57:18] core.filemode=true [2022/01/04 15:57:18] core.bare=false [2022/01/04 15:57:18] core.logallrefupdates=true [2022/01/04 15:57:18] remote.origin.url=http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@git.***.com/finance/order-center.git [2022/01/04 15:57:18] remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* [2022/01/04 15:57:18] branch.master.remote=origin [2022/01/04 15:57:18] branch.master.merge=refs/heads/master
要使用 ssh 从私有存储库获取代码,我运行
[2022/01/04 15:57:23] Step 20/22 : RUN git config --global --unset url.http://git.***.com/.insteadof
正确答案
你可以检查这个代码 https://github.com/golang/go/blob/b1a53ece68d46e4fb59c74d2bc529060861f5dbf/src/cmd/go/internal/vcs/vcs.go#L242-L246 一般来说,当 go get 或下载 mod 时,会调用 git ls-remote (go build 会下载当前构建所依赖的远程模块)。
终于介绍完啦!小伙伴们,这篇关于《什么时候在使用 go 模块执行 `go build` 时会执行 `git ls-remote -q origin` ?》的介绍应该让你收获多多了吧!欢迎大家收藏或分享给更多需要学习的朋友吧~golang学习网公众号也会发布Golang相关知识,快来关注吧!
本文内容来源于互联网,如有侵权请联系删除。
近期热门
站内热门
最新文章
热门专题
