dongshan3806 2012-09-13 10:21 采纳率: 0%
浏览 86
已采纳

设置Go软件包的Mercurial存储库

I am struggling to setup a local Mercurial repository for go packages.

All mercurial package directories can are under the following url:

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

I can clone a package via:

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

That works fine.

When I want to install the package with the go command line:

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

I get the following error:

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

But when I do it as explained in http://golang.org/cmd/go/ :

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

It works perfectly.

In the above document they talk about a <meta> flag. So I created a index.html with the following entry:

<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>

Update:

When I do a wget -O- https://server.example.com/go-packages/packagename/?go-get=1 --no-check-certificate I get:

!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>

Update 2

I saw, that my content was wrong (copy paste error) now I changed it to:

<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>

Where go-packages is a directory containing the mercurial repository packagename.

But still go get server.example.com/go-packages/packagename is not working.

  • 写回答

1条回答 默认 最新

  • dongtang1918 2012-09-13 11:00
    关注

    After looking at this issue (and attached code review), and this thread:

    • make sure your "import-prefix hg repo-root" follows the right format
      • The import-alias-prefix must be a prefix or exact match of the package being fetched with "go get".
      • The full-repo-root must be a full URL root to a repository containing a scheme and not containing a ".vcs" qualifier.
      • The vcs is one of "git", "hg", "svn", etc.
    • make sure the page fetch from https://<import>?go-get=1 is indeed you index.html page (not index.htm or any other DirectoryIndex directive, if this is setup in an httpd.conf file for instance)

    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.

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

报告相同问题?

悬赏问题

  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误