gpt4 book ai didi

mercurial - 为 Go 包设置 Mercurial 存储库

转载 作者:IT王子 更新时间:2023-10-29 01:03:47 26 4
gpt4 key购买 nike

我正在努力为 go 包设置本地 Mercurial 存储库。

所有 mercurial 包目录都可以在以下 url 下:

https://server.example.com/go-packages/

我可以通过以下方式克隆一个包:

hg clone https://server.example.com/go-packages/packagename

这很好。

当我想安装带有 go 的包时命令行:

go get server.example.com/go-packages/packagename

我收到以下错误:

package server.example.com/go-packages/packagename: unrecognized import path "server.example.com/go-packages/packagename"

但是当我按照 http://golang.org/cmd/go/ 中的说明进行操作时:

go get server.example.com/go-packages/packagename.hg

它工作得很好。

在上面的文档中,他们讨论了一个 <meta>旗帜。所以我创建了一个包含以下条目的 index.html:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="go-import" content="import-prefix hg repo-root">
<title>packagename</title>
</head>
<body>
<h1>packagename</h1>
</body>
</html>

更新:

当我执行 wget -O- https://server.example.com/go-packages/packagename/?go-get=1 --no-check-certificate 时我得到:

!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="go-import" content="import-prefix hg repo-root">
<title>packagename</title>
</head>
<body>
<h1>packagename</h1>
</body>
</html>

更新2

我看到,我的内容是错误的(复制粘贴错误)现在我把它改成了:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="go-import" content="server.example.com/go-packages/packagename hg https://server.example.com/go-packages/packagename" />
<title>packagename</title>
</head>
<body>
<h1>packagename</h1>
</body>
</html>

在哪里go-packages是包含 mercurial 存储库的目录 packagename .

但还是go get server.example.com/go-packages/packagename不管用。

最佳答案

看了this issue之后(并附上 code review )和 this thread :

  • 确保你的“import-prefix hg repo-root”遵循正确的格式
    • 导入别名前缀必须是前缀或完全匹配使用“go get”获取包。
    • full-repo-root 必须是包含以下内容的存储库的完整 URL 根目录一个方案,包含“.vcs”限定符。
    • vcs是“git”、“hg”、“svn”等之一
  • 确保页面从 https://<import>?go-get=1 获取确实是你index.html页面(不是 index.htm 或任何其他 DirectoryIndex 指令,例如,如果这是在 httpd.conf 文件中设置的)

If the import-alias-prefix is not an exact match for the import, another HTTP fetch is performed, at the declared root (which does not need to be the domain's root).

For example, assuming that "camlistore.org/pkg/blobref" declares in its HTML head:

<meta name="go-import" content="camlistore.org git https://camlistore.org/r/p/camlistore" />

... then:

$ go get camlistore.org/pkg/blobref

... looks at the following URLs:

https://camlistore.org/pkg/blobref?go-get=1
http://camlistore.org/pkg/blobref?go-get=1
https://camlistore.org/?go-get=1
http://camlistore.org/?go-get=1

Ultimately it finds, at the root (camlistore.org/), the same go-import:

<meta name="go-import" content="camlistore.org git https://camlistore.org/r/p/camlistore" />

... and proceeds to trust it, checking out git //camlistore.org/r/p/camlistore at the import path of "camlistore.org" on disk.

关于mercurial - 为 Go 包设置 Mercurial 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12404109/

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