Skip to content

Commit 59d9e0e

Browse files
author
Jay Conrod
committed
_content/doc: add reference on serving a module directly from a proxy
This was hinted at in "Finding a repository for a module path", but this change makes the functionality more explicit and provides and example. Change-Id: I9a60c1d19c53108e8ae20112fcb3e88d97413677 Reviewed-on: https://go-review.googlesource.com/c/website/+/322670 Trust: Jay Conrod <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
1 parent 45cb069 commit 59d9e0e

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

_content/ref/mod.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2453,6 +2453,43 @@ entirely. See [Authenticating modules](#authenticating) for more
24532453
information. Note that version lists and version metadata returned for `.info`
24542454
requests are not authenticated and may change over time.
24552455

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+
24562493
## Version control systems {#vcs}
24572494

24582495
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.
25162553
`hg`, `svn`, `mod`. The `mod` scheme instructs the `go` command to download the
25172554
module from the given URL using the [`GOPROXY`
25182555
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.
25202558

25212559
`repo-url` is the repository's URL. If the URL does not include a scheme (either
25222560
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
37983836
comment](#go-mod-file-module-deprecation) in the latest version of its
37993837
[`go.mod` file](#glos-go-mod-file).
38003838

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+
38013846
<a id="glos-go-mod-file"></a>
38023847
**`go.mod` file:** The file that defines a module's path, requirements, and
38033848
other metadata. Appears in the [module's root

0 commit comments

Comments
 (0)