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

设置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
    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.

    点赞 评论

相关推荐