@@ -2453,6 +2453,43 @@ entirely. See [Authenticating modules](#authenticating) for more
2453
2453
information. Note that version lists and version metadata returned for ` .info `
2454
2454
requests are not authenticated and may change over time.
2455
2455
2456
+ ### Serving modules directly from a proxy {#serving-from-proxy}
2457
+
2458
+ Most modules are developed and served from a version control repository. In
2459
+ [ direct mode] ( #glos-direct-mode ) , the ` go ` command downloads such a module with
2460
+ a version control tool (see [ Version control systems] ( #vcs ) ). It's also possible
2461
+ to serve a module directly from a module proxy. This is useful for organizations
2462
+ that want to serve modules without exposing their version control servers and
2463
+ for organizations that use version control tools the ` go ` command does not
2464
+ support.
2465
+
2466
+ When the ` go ` command downloads a module in direct mode, it first looks up the
2467
+ module server's URL with an HTTP GET request based on the module path. It looks
2468
+ for a ` <meta> ` tag with the name ` go-import ` in the HTML response. The tag's
2469
+ content must contain the [ repository root
2470
+ path] ( #glos-repository-root-path ) , the version control system, and the URL,
2471
+ separated by spaces. See [ Finding a repository for a module path] ( #vcs-find ) for
2472
+ details.
2473
+
2474
+ If the version control system is ` mod ` , the ` go ` command downloads the module
2475
+ from the given URL using the [ ` GOPROXY ` protocol] ( #goproxy-protocol ) .
2476
+
2477
+ For example, suppose the ` go ` command is attempting to download the module
2478
+ ` example.com/gopher ` at version ` v1.0.0 ` . It sends a request to
2479
+ ` https://example.com/gopher?go-get=1 ` . The server responds with an HTML document
2480
+ containing the tag:
2481
+
2482
+ ```
2483
+ <meta name="go-import" content="example.com/gopher mod https://modproxy.example.com">
2484
+ ```
2485
+
2486
+ Based on this response, the ` go ` command downloads the module by sending
2487
+ requests for ` https://modproxy.example.com/example.com/gopher/@v/v1.0.0.info ` ,
2488
+ ` v1.0.0.mod ` , and ` v1.0.0.zip ` .
2489
+
2490
+ Note that modules served directly from a proxy cannot be downloaded with
2491
+ ` go get ` in GOPATH mode.
2492
+
2456
2493
## Version control systems {#vcs}
2457
2494
2458
2495
The ` go ` command may download module source code and metadata directly from a
@@ -2516,7 +2553,8 @@ is made for the prefix to verify the `<meta>` tags match.
2516
2553
` hg ` , ` svn ` , ` mod ` . The ` mod ` scheme instructs the ` go ` command to download the
2517
2554
module from the given URL using the [ ` GOPROXY `
2518
2555
protocol] ( #goproxy-protocol ) . This allows developers to distribute modules
2519
- without exposing source repositories.
2556
+ without exposing source repositories. See [ Serving modules directly from a
2557
+ proxy] ( #serving-from-proxy ) for details.
2520
2558
2521
2559
` repo-url ` is the repository's URL. If the URL does not include a scheme (either
2522
2560
because the module path has a VCS qualifier or because the ` <meta> ` tag lacks a
@@ -3798,6 +3836,13 @@ A deprecated module is marked with a [deprecation
3798
3836
comment] ( #go-mod-file-module-deprecation ) in the latest version of its
3799
3837
[ ` go.mod ` file] ( #glos-go-mod-file ) .
3800
3838
3839
+ <a id =" glos-direct-mode " ></a >
3840
+ ** direct mode:** A setting of [ environment variables] ( #environment-variables )
3841
+ that causes the ` go ` command to download a module directly from a [ version
3842
+ control system] ( #vcs ) , as opposed to a [ module proxy] ( #glos-module-proxy ) .
3843
+ ` GOPROXY=direct ` does this for all modules. ` GOPRIVATE ` and ` GONOPROXY ` do this
3844
+ for modules matching a list of patterns.
3845
+
3801
3846
<a id =" glos-go-mod-file " ></a >
3802
3847
** ` go.mod ` file:** The file that defines a module's path, requirements, and
3803
3848
other metadata. Appears in the [ module's root
0 commit comments