Reputation: 2502
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>
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>
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.
Upvotes: 3
Views: 1836
Reputation: 1328192
After looking at this issue (and attached code review), and this thread:
go get
"..vcs
" qualifier.vcs
is one of "git
", "hg
", "svn
", etc.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 samego-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.
Upvotes: 4