gpt4 book ai didi

go - 如何通过 SSH 使用 Mercurial 进行导入?

转载 作者:行者123 更新时间:2023-12-02 11:24:37 24 4
gpt4 key购买 nike

是否可以使用 Mercurial 和 ssh 导入模块?

我发现很少有关于在 go 中使用 Mercurial 的信息,而且我发现的很少是在 http 中使用的。

最佳答案

简短的回答是肯定的。

go help importpath 显示的文本,或可用 here ,描述如何设置导入路径以暗示特定的版本控制系统。有些网站是预先知道的:

A few common code hosting sites have special syntax:
[list snipped, but GitHub implies using Git protocol, Launchpad implies Bazaar, and so on]

For code hosted on other servers, import paths may either be qualified with the version control type, or the go tool can dynamically fetch the import path over https/http and discover where the code resides from a <meta> tag in the HTML.

因此,如果您无权访问或控制此类 <meta>标签,您应该使用明确指定的 VCS 导入:

... an import path of the form

repository.vcs/path

specifies the given repository, with or without the .vcs suffix, using the named version control system, and then the path inside that repository.

即告诉go get它必须使用 Mercurial 协议(protocol)才能托管 example.com你可能会使用:

import "example.com/me.hg/repo"

或者:

import "example.com/me/repo.hg"

其中 .hg这意味着使用 Mercurial。

一旦您选择了特定的 VCS,事情就会变得有点棘手:

When a version control system supports multiple protocols, each is tried in turn when downloading. For example, a Git download tries https://, then git+ssh://.

source code Go VCS 导入器有详细信息。 Mercurial 存储库导入尝试 https首先,然后ssh .

如果您可以使用<meta>标签,that可以提供更多细节,这样就可以避免相对笨拙的 .hg在导入路径中:

If the import path is not a known code hosting site and also lacks a version control qualifier, the go tool attempts to fetch the import over https/http and looks for a <meta> tag in the document's HTML <head>.

如果您正在实现 <meta>响应请求页面,阅读其余部分的全部,因为这继续说:

When using modules, an additional variant of the go-import meta tag is recognized and is preferred over those listing version control systems. That variant uses "mod" as the vcs in the content value, as in:

<meta name="go-import" content="example.org mod https://code.org/moduleproxy">

This tag means to fetch modules with paths beginning with example.org from the module proxy available at the URL https://code.org/moduleproxy. See 'go help goproxy' for details about the proxy protocol.

关于go - 如何通过 SSH 使用 Mercurial 进行导入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64095264/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com