设置go mod download命令的协议。

huangapple go评论84阅读模式
英文:

Set protocol for go mod download command

问题

我有一个go库,其源代码存储在私有存储库(Azure DevOps git)中。另一个go项目将此库作为依赖项引用。引用的模块路径具有类似于以下内容的版本控制系统限定符:

dev.azure.com/<organization>/<project>/_git/<repo>.git

我将GOPRIVATE设置为dev.azure.com/<organization>。这确保go命令将从版本控制存储库下载匹配的模块,因为它们是在那里开发的。

当运行go mod download命令时,它首先克隆存储库,然后对其进行压缩。为了从版本控制系统克隆存储库,它使用ssh而不是https。我如何告诉go命令改用https而不是ssh

文档中提到:

>如果模块路径具有VCS限定符(.bzr、.fossil、.git、.hg、.svn中的一个)作为路径组件的结尾,go命令将使用该路径限定符之前的所有内容作为存储库URL。例如,对于模块example.com/foo.git/bar,go命令使用git下载example.com/foo.git上的存储库,并期望在bar子目录中找到该模块。go命令将根据版本控制工具支持的协议猜测要使用的协议。

英文:

I've a go library, the source for which resides in a private repository (Azure DevOps git). Another go project references this library as a dependency. The referenced module path has a VCS qualifier like this:

dev.azure.com/&lt;organization&gt;/&lt;project&gt;/_git/&lt;repo&gt;.git

I set the GOPRIAVTE to dev.azure.com/&lt;organization&gt;. This ensures that the go command will download matching modules from version control repositories where they’re developed.

When go mod download command is run, it first clones the repository and then zips it. To clone the repo from vcs, it uses the ssh instead of https. How do I tell the go command to use https instead on ssh ?

Here is what the doc says:

>If the module path has a VCS qualifier (one of .bzr, .fossil, .git, .hg, .svn) at the end of a path component, the go command will use everything up to that path qualifier as the repository URL. For example, for the module example.com/foo.git/bar, the go command downloads the repository at example.com/foo.git using git, expecting to find the module in the bar subdirectory. The go command will guess the protocol to use based on the protocols supported by the version control tool.

答案1

得分: 1

你的问题实际上是一个关于Git的问题,答案是:

git config --global url.ssh://git@your.private.git/.insteadOf https://your.private.git/
英文:

Your question is really a git question, the answer is:

git config --global url.ssh://git@your.private.git/.insteadOf https://your.private.git/

huangapple
  • 本文由 发表于 2023年2月28日 01:02:08
  • 转载请务必保留本文链接:https://go.coder-hub.com/75583428.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定