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.

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

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度