]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: add 'go help goproxy'
authorRuss Cox <rsc@golang.org>
Tue, 24 Jul 2018 19:07:19 +0000 (15:07 -0400)
committerRuss Cox <rsc@golang.org>
Sat, 28 Jul 2018 01:15:05 +0000 (01:15 +0000)
Fixes #26553.

Change-Id: I522a0fa96ae161b67d89f38dafde528adcbae243
Reviewed-on: https://go-review.googlesource.com/125658
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/cmd/go/alldocs.go
src/cmd/go/main.go

index e92d293ccd3d5c362bbfb8f57113fbda35c6296c..ef1a202e29145ad7c34cfab0878e94a32c18ae05 100644 (file)
@@ -42,6 +42,7 @@
 //     filetype    file types
 //     gopath      GOPATH environment variable
 //     gopath-get  legacy GOPATH go get
+//     goproxy     module proxy protocol
 //     importpath  import path syntax
 //     modules     modules, module versions, and more
 //     module-get  module-aware go get
 //         Main     bool         // is this the main module?
 //         Indirect bool         // is this module only an indirect dependency of main module?
 //         Dir      string       // directory holding files for this module, if any
+//         GoMod    string       // go.mod file for this module, if any
 //         Error    *ModuleError // error loading module
 //     }
 //
 //     GOTMPDIR
 //             The directory where the go command will write
 //             temporary source files, packages, and binaries.
-//     GOTOOLDIR
-//             The directory where the go tools (compile, cover, doc, etc...)
-//             are installed. This is printed by go env, but setting the
-//             environment variable has no effect.
 //
 // Environment variables for use with cgo:
 //
 //             with git fetch/clone. If set, any scheme not explicitly mentioned will be
 //             considered insecure by 'go get'.
 //
+// Additional information available from 'go env' but not read from the environment:
+//
+//     GOEXE
+//             The executable file name suffix (".exe" on Windows, "" on other systems).
+//     GOHOSTARCH
+//             The architecture (GOARCH) of the Go toolchain binaries.
+//     GOHOSTOS
+//             The operating system (GOOS) of the Go toolchain binaries.
+//     GOMOD
+//             The absolute path to the go.mod of the main module,
+//             or the empty string if not using modules.
+//     GOTOOLDIR
+//             The directory where the go tools (compile, cover, doc, etc...) are installed.
+//
 //
 // File types
 //
 // See https://golang.org/s/go15vendor for details.
 //
 //
+// Module proxy protocol
+//
+// The go command by default downloads modules from version control systems
+// directly, just as 'go get' always has. If the GOPROXY environment variable
+// is set to the URL of a module proxy, the go command will instead fetch
+// all modules from that proxy. No matter the source of the modules, downloaded
+// modules must match existing entries in go.sum (see 'go help modules' for
+// discussion of verification).
+//
+// A Go module proxy is any web server that can respond to GET requests for
+// URLs of a specified form. The requests have no query parameters, so even
+// a site serving from a fixed file system (including a file:/// URL)
+// can be a module proxy.
+//
+// The GET requests sent to a Go module proxy are:
+//
+// GET $GOPROXY/<module>/@v/list returns a list of all known versions of the
+// given module, one per line.
+//
+// GET $GOPROXY/<module>/@v/<version>.info returns JSON-formatted metadata
+// about that version of the given module.
+//
+// GET $GOPROXY/<module>/@v/<version>.mod returns the go.mod file
+// for that version of the given module.
+//
+// GET $GOPROXY/<module>/@v/<version>.zip returns the zip archive
+// for that version of the given module.
+//
+// To avoid problems when serving from case-sensitive file systems,
+// the <module> and <version> elements are case-encoded, replacing every
+// uppercase letter with an exclamation mark followed by the correponding
+// lower-case letter: github.com/Azure encodes as github.com/!azure.
+//
+// The JSON-formatted metadata about a given module corresponds to
+// this Go data structure, which may be expanded in the future:
+//
+//     type Info struct {
+//         Version string    // version string
+//         Time    time.Time // commit time
+//     }
+//
+// The zip archive for a specific version of a given module is a
+// standard zip file that contains the file tree corresponding
+// to the module's source code and related files. The archive uses
+// slash-separated paths, and every file path in the archive must
+// begin with <module>@<version>/, where the module and version are
+// substituted directly, not case-encoded. The root of the module
+// file tree corresponds to the <module>@<version>/ prefix in the
+// archive.
+//
+// Even when downloading directly from version control systems,
+// the go command synthesizes explicit info, mod, and zip files
+// and stores them in its local cache, $GOPATH/src/mod/cache/download,
+// the same as if it had downloaded them directly from a proxy.
+// The cache layout is the same as the proxy URL space, so
+// serving $GOPATH/src/mod/cache/download at (or copying it to)
+// https://example.com/proxy would let other users access those
+// cached module versions with GOPROXY=https://example.com/proxy.
+//
+//
 // Import path syntax
 //
 // An import path (see 'go help packages') denotes a package stored in the local
index 5deb7265d7f5798a3a9a33c1e6e511190fa52e51..607db57d8a4d0b45ad36c016446501e94abaefe2 100644 (file)
@@ -28,6 +28,7 @@ import (
        "cmd/go/internal/help"
        "cmd/go/internal/list"
        "cmd/go/internal/modcmd"
+       "cmd/go/internal/modfetch"
        "cmd/go/internal/modget"
        "cmd/go/internal/modload"
        "cmd/go/internal/run"
@@ -65,6 +66,7 @@ func init() {
                help.HelpFileType,
                help.HelpGopath,
                get.HelpGopathGet,
+               modfetch.HelpGoproxy,
                help.HelpImportPath,
                modload.HelpModules,
                modget.HelpModuleGet,