]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: document import path meta tag discovery in go help remote
authorBrad Fitzpatrick <bradfitz@golang.org>
Thu, 8 Mar 2012 19:31:52 +0000 (11:31 -0800)
committerBrad Fitzpatrick <bradfitz@golang.org>
Thu, 8 Mar 2012 19:31:52 +0000 (11:31 -0800)
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5787059

src/cmd/go/doc.go
src/cmd/go/help.go

index 80938087d0e2059701192e6a056046fd22727d1c..45278a6d714b8ac238c272bd08bb64bf74acb48c 100644 (file)
@@ -564,7 +564,12 @@ A few common code hosting sites have special syntax:
                import "launchpad.net/~user/project/branch"
                import "launchpad.net/~user/project/branch/sub/directory"
 
-For code hosted on other servers, an import path of the form
+For code hosted on other servers, import paths may either be qualified
+with the version control type, or the go tool can dynamically fetch
+the import path over https/http and discover where the code resides
+from a <meta> tag in the HTML.
+
+To declare the code location, an import path of the form
 
        repository.vcs/path
 
@@ -593,6 +598,42 @@ When a version control system supports multiple protocols,
 each is tried in turn when downloading.  For example, a Git
 download tries git://, then https://, then http://.
 
+If the import path is not a known code hosting site and also lacks a
+version control qualifier, the go tool attempts to fetch the import
+over https/http and looks for a <meta> tag in the document's HTML
+<head>.
+
+The meta tag has the form:
+
+       <meta name="go-import" content="import-prefix vcs repo-root">
+
+The import-prefix is the import path correponding to the repository
+root. It must be a prefix or an exact match of the package being
+fetched with "go get". If it's not an exact match, another http
+request is made at the prefix to verify the <meta> tags match.
+
+The vcs is one of "git", "hg", "svn", etc,
+
+The repo-root is the root of the version control system
+containing a scheme and not containing a .vcs qualifier.
+
+For example,
+
+       import "example.org/pkg/foo"
+
+will result in the following request(s):
+
+       https://example.org/pkg/foo?go-get=1 (preferred)
+       http://example.org/pkg/foo?go-get=1  (fallback)
+
+If that page contains the meta tag
+
+       <meta name="go-import" content="example.org git https://code.org/r/p/exproj">
+
+the go tool will verify that https://example.org/?go-get=1 contains the
+same meta tag and then git clone https://code.org/r/p/exproj into
+GOPATH/src/example.org.
+
 New downloaded packages are written to the first directory
 listed in the GOPATH environment variable (see 'go help gopath').
 
index 60654a27200ab63d1aa94cacd650f27aeb6d8792..1d1dae37d19c62f769a60a6dde5aff6474c45c3b 100644 (file)
@@ -96,7 +96,12 @@ A few common code hosting sites have special syntax:
                import "launchpad.net/~user/project/branch"
                import "launchpad.net/~user/project/branch/sub/directory"
 
-For code hosted on other servers, an import path of the form
+For code hosted on other servers, import paths may either be qualified
+with the version control type, or the go tool can dynamically fetch
+the import path over https/http and discover where the code resides
+from a <meta> tag in the HTML.
+
+To declare the code location, an import path of the form
 
        repository.vcs/path
 
@@ -125,6 +130,42 @@ When a version control system supports multiple protocols,
 each is tried in turn when downloading.  For example, a Git
 download tries git://, then https://, then http://.
 
+If the import path is not a known code hosting site and also lacks a
+version control qualifier, the go tool attempts to fetch the import
+over https/http and looks for a <meta> tag in the document's HTML
+<head>.
+
+The meta tag has the form:
+
+       <meta name="go-import" content="import-prefix vcs repo-root">
+
+The import-prefix is the import path correponding to the repository
+root. It must be a prefix or an exact match of the package being
+fetched with "go get". If it's not an exact match, another http
+request is made at the prefix to verify the <meta> tags match.
+
+The vcs is one of "git", "hg", "svn", etc,
+
+The repo-root is the root of the version control system
+containing a scheme and not containing a .vcs qualifier.
+
+For example,
+
+       import "example.org/pkg/foo"
+
+will result in the following request(s):
+
+       https://example.org/pkg/foo?go-get=1 (preferred)
+       http://example.org/pkg/foo?go-get=1  (fallback)
+
+If that page contains the meta tag
+
+       <meta name="go-import" content="example.org git https://code.org/r/p/exproj">
+
+the go tool will verify that https://example.org/?go-get=1 contains the
+same meta tag and then git clone https://code.org/r/p/exproj into
+GOPATH/src/example.org.
+
 New downloaded packages are written to the first directory
 listed in the GOPATH environment variable (see 'go help gopath').