diff --git a/content/static/doc/mod.md b/content/static/doc/mod.md index ea4e48599b..eeefb43225 100644 --- a/content/static/doc/mod.md +++ b/content/static/doc/mod.md @@ -2382,8 +2382,8 @@ requires some configuration. The environment variables below may be used to configure access to private modules. See [Environment variables](#environment-variables) for details. See -also [Privacy](#privacy) for information on controlling information sent to -public servers. +also [Privacy](#private-module-privacy) for information on controlling +information sent to public servers. * `GOPROXY` — list of module proxy URLs. The `go` command will attempt to download modules from each server in sequence. The keyword `direct` instructs @@ -2545,6 +2545,105 @@ GOPROXY=https://jrgopher:hunter2@proxy.corp.example.com Use caution when taking this approach: environment variables may be appear in shell history and in logs. +### Privacy {#private-module-privacy} + +The `go` command may download modules and metadata from module proxy +servers and version control systems. The environment variable `GOPROXY` +controls which servers are used. The environment variables `GOPRIVATE` and +`GONOPROXY` control which modules are fetched from proxies. + +The default value of `GOPROXY` is: + +``` +https://proxy.golang.org,direct +``` + +With this setting, when the `go` command downloads a module or module metadata, +it will first send a request to `proxy.golang.org`, a public module proxy +operated by Google ([privacy policy](https://proxy.golang.org/privacy)). See +[`GOPROXY` protocol](#goproxy-protocol) for details on what information is sent +in each request. The `go` command does not transmit personally identifiable +information, but it does transmit the full module path being requested. If the +proxy responds with a 404 (Not Found) or 410 (Gone) status, the `go` command +will attempt to connect directly to the version control system providing the +module. See [Version control systems](#vcs) for details. + +The `GOPRIVATE` or `GONOPROXY` environment variables may be set to lists of glob +patterns matching module prefixes that are private and should not be requested +from any proxy. For example: + +``` +GOPRIVATE=*.corp.example.com,*.research.example.com +``` + +`GOPRIVATE` simply acts as a default for `GONOPROXY` and `GONOSUMDB`, so it's +not necessary to set `GONOPROXY` unless `GONOSUMDB` should have a different +value. When a module path is matched by `GONOPROXY`, the `go` command ignores +`GOPROXY` for that module and fetches it directly from its version control +repository. This is useful when no proxy serves private modules. See [Direct +access to private modules](#private-module-proxy-direct). + +If there is a [trusted proxy serving all modules](#private-module-proxy-all), +then `GONOPROXY` should not be set. For example, if `GOPROXY` is set to one +source, the `go` command will not download modules from other sources. +`GONOSUMDB` should still be set in this situation. + +``` +GOPROXY=https://proxy.corp.example.com +GONOSUMDB=*.corp.example.com,*.research.example.com +``` + +If there is a [trusted proxy serving only private +modules](#private-module-proxy-private), `GONOPROXY` should not be set, but care +must be taken to ensure the proxy responds with the correct status codes. For +example, consider the following configuration: + +``` +GOPROXY=https://proxy.corp.example.com,https://proxy.golang.org +GONOSUMDB=*.corp.example.com,*.research.example.com +``` + +Suppose that due to a typo, a developer attempts to download a module that +doesn't exist. + +``` +go mod download corp.example.com/secret-product/typo@latest +``` + +The `go` command first requests this module from `proxy.corp.example.com`. If +that proxy responds with 404 (Not Found) or 410 (Gone), the `go` command will +fall back to `proxy.golang.org`, transmitting the `secret-product` path in the +request URL. If the private proxy responds with any other error code, the `go` +command prints the error and will not fall back to other sources. + +In addition to proxies, the `go` command may connect to the checksum database to +verify cryptographic hashes of modules not listed in `go.sum`. The `GOSUMDB` +environment variable sets the name, URL, and public key of the checksum +database. The default value of `GOSUMDB` is `sum.golang.org`, the public +checksum database operated by Google ([privacy +policy](https://sum.golang.org/privacy)). See [Checksum +database](#checksum-database) for details on what is transmitted with each +request. As with proxies, the `go` command does not transmit personally +identifiable information, but it does transmit the full module path being +requested, and the checksum database cannot compute checksums for non-public +modules. + +The `GONOSUMDB` environment variable may be set to patterns indicating which +modules are private and should not be requested from the checksum +database. `GOPRIVATE` acts as a default for `GONOSUMDB` and `GONOPROXY`, so it's +not necessary to set `GONOSUMDB` unless `GONOPROXY` should have a +different value. + +A proxy may [mirror the checksum +database](https://go.googlesource.com/proposal/+/master/design/25530-sumdb.md#proxying-a-checksum-database). +If a proxy in `GOPROXY` does this, the `go` command will not connect to the +checksum database directly. + +`GOSUMDB` may be set to `off` to disable use of the checksum database +entirely. With this setting, the `go` command will not authenticate downloaded +modules unless they're already in `go.sum`. See [Authenticating +modules](#authenticating). + ## Module cache {#module-cache} The module cache is the directory where the `go` command stores @@ -2894,8 +2993,6 @@ The `go env -w` command can be used to [set these variables](/pkg/cmd/go/#hdr-Print_Go_environment_information) for future `go` command invocations. -## Privacy {#privacy} - ## Environment variables {#environment-variables} Module behavior in the `go` command may be configured using the environment @@ -2982,7 +3079,8 @@ of all environment variables recognized by the `go` command.

If GONOPROXY is not set, it defaults to - GOPRIVATE. See Privacy. + GOPRIVATE. See + Privacy.

@@ -2997,7 +3095,8 @@ of all environment variables recognized by the `go` command.

If GONOSUMDB is not set, it defaults to - GOPRIVATE. See Privacy. + GOPRIVATE. See + Privacy.

@@ -3028,7 +3127,7 @@ of all environment variables recognized by the `go` command. prefixes that should be considered private. GOPRIVATE is a default value for GONOPROXY and GONOSUMDB. GOPRIVATE itself has no other - meaning. See Privacy. + meaning. See Privacy. @@ -3078,7 +3177,7 @@ of all environment variables recognized by the `go` command. for the mirror's privacy policy. The GOPRIVATE and GONOPROXY environment variables may be set to prevent specific modules from being downloaded using proxies. See - Privacy for information on + Privacy for information on private proxy configuration.

@@ -3126,7 +3225,7 @@ GOSUMDB="sum.golang.org+<publickey> https://sum.golang.org

See Authenticating modules and - Privacy for more information. + Privacy for more information.

diff --git a/content/static/static.go b/content/static/static.go index 4e1b504d97..b5b27a48ab 100644 --- a/content/static/static.go +++ b/content/static/static.go @@ -153,5 +153,5 @@ var Files = map[string]string{ "style.css": "body\x20{\x0a\x20\x20background-color:\x20#fff;\x0a\x20\x20color:\x20#3e4042;\x0a\x20\x20font-family:\x20Roboto,\x20Arial,\x20sans-serif;\x0a\x20\x20line-height:\x201.3;\x0a\x20\x20margin:\x200;\x0a\x20\x20text-align:\x20center;\x0a}\x0a.Note\x20{\x0a\x20\x20/*\x20For\x20styling\x20\"Note\"\x20sections.\x20*/\x0a\x20\x20background-color:\x20rgb(224,\x20235,\x20245);\x0a\x20\x20font-size:\x200.875rem;\x0a\x20\x20margin:\x201.25rem;\x0a\x20\x20max-width:\x2050rem;\x0a\x20\x20padding:\x200.5rem\x200.5rem\x200.5rem\x200.625rem;\x0a}\x0a/*\x20Tabs\x20*/\x0a.TabSection\x20{\x0a\x20\x20background:\x20#fff;\x0a\x20\x20border:\x200.0625rem\x20solid\x20#dadce0;\x0a\x20\x20border-radius:\x200.3125rem;\x0a\x20\x20box-shadow:\x20none;\x0a\x20\x20max-width:\x2050rem;\x0a}\x0a.TabSection-tabList\x20{\x0a\x20\x20flex-shrink:\x200;\x0a\x20\x20position:\x20relative;\x0a\x20\x20border-bottom:\x200.0625rem\x20solid\x20#dadce0;\x0a}\x0a.TabSection-tab\x20{\x0a\x20\x20background:\x20#fff;\x0a\x20\x20border:\x20none;\x0a\x20\x20line-height:\x203rem;\x0a\x20\x20padding:\x200\x201.125rem;\x0a\x20\x20position:\x20relative;\x0a}\x0a.TabSection-tab[aria-selected='true']\x20{\x0a\x20\x20outline:\x200;\x0a\x20\x20background-color:\x20#e0ebf5;\x0a}\x0a.TabSection-tab:focus\x20{\x0a\x20\x20outline:\x200;\x0a\x20\x20background-color:\x20#e0ebf5;\x0a}\x0a.TabSection-tabPanel\x20{\x0a\x20\x20font-size:\x200.875rem;\x0a}\x0a/*\x20Tutorial\x20previous\x20and\x20next\x20links\x20*/\x0a.Navigation\x20{\x0a\x20\x20font-size:\x200.875rem;\x0a}\x0a.Navigation-prev\x20{\x0a\x20\x20float:\x20left;\x0a\x20\x20font-weight:\x20bold;\x0a}\x0a.Navigation-next\x20{\x0a\x20\x20float:\x20right;\x0a\x20\x20font-weight:\x20bold;\x0a}\x0a/*\x20Table\x20in\x20doc\x20topics.\x20*/\x0a.DocTable\x20{\x0a\x20\x20border-collapse:\x20collapse;\x0a\x20\x20font-size:\x200.875rem;\x0a\x20\x20margin:\x201.25rem;\x0a\x20\x20max-width:\x2050rem;\x0a}\x0a.DocTable-row\x20{\x0a\x20\x20border-bottom:\x200.0625rem\x20solid\x20#dadce0;\x0a\x20\x20height:\x203rem;\x0a\x20\x20vertical-align:\x20middle;\x0a}\x0a.DocTable-head\x20{\x0a\x20\x20background:\x20#e8eaed;\x0a\x20\x20border-bottom:\x200.0625rem\x20solid\x20#dadce0;\x0a\x20\x20border-top:\x200.0625rem\x20solid\x20#dadce0;\x0a\x20\x20height:\x203rem;\x0a}\x0a.DocTable-cell\x20{\x0a\x20\x20padding:\x200rem\x200.4375rem;\x0a}\x0a.DocTable-row--highlighted\x20{\x0a\x20\x20background:\x20#f0f0f0;\x0a\x20\x20border-bottom:\x200.0625rem\x20solid\x20#dadce0;\x0a\x20\x20height:\x203rem;\x0a}\x0atextarea\x20{\x0a\x20\x20/*\x20Inherit\x20text\x20color\x20from\x20body\x20avoiding\x20illegible\x20text\x20in\x20the\x20case\x20where\x20the\x0a\x20\x20\x20*\x20user\x20has\x20inverted\x20the\x20browsers\x20custom\x20text\x20and\x20background\x20colors.\x20*/\x0a\x20\x20color:\x20inherit;\x0a}\x0apre,\x0acode\x20{\x0a\x20\x20font-family:\x20Menlo,\x20monospace;\x0a\x20\x20font-size:\x200.875rem;\x0a}\x0acode\x20{\x0a\x20\x20/*\x20Reduce\x20spacing\x20between\x20words\x20in\x20code\x20inline\x20with\x20text.\x20Monospace\x20font\x0a\x20\x20\x20*\x20spaces\x20tend\x20to\x20be\x20wider\x20than\x20proportional\x20font\x20spaces.\x20*/\x0a\x20\x20word-spacing:\x20-0.3em;\x0a}\x0apre\x20{\x0a\x20\x20line-height:\x201.4;\x0a\x20\x20overflow-x:\x20auto;\x0a}\x0apre\x20.comment\x20{\x0a\x20\x20color:\x20#006600;\x0a}\x0apre\x20.highlight,\x0apre\x20.highlight-comment,\x0apre\x20.selection-highlight,\x0apre\x20.selection-highlight-comment\x20{\x0a\x20\x20background:\x20#ffff00;\x0a}\x0apre\x20.selection,\x0apre\x20.selection-comment\x20{\x0a\x20\x20background:\x20#ff9632;\x0a}\x0apre\x20.ln\x20{\x0a\x20\x20color:\x20#999;\x0a\x20\x20background:\x20#efefef;\x0a}\x0apre\x20ins\x20{\x0a\x20\x20/*\x20For\x20styling\x20highlighted\x20code\x20in\x20examples.\x20*/\x0a\x20\x20color:\x20rgb(0,\x20125,\x20156);\x0a\x20\x20font-weight:\x20bold;\x0a\x20\x20text-decoration:\x20none;\x0a}\x0a.ln\x20{\x0a\x20\x20user-select:\x20none;\x0a\x0a\x20\x20/*\x20Ensure\x208\x20characters\x20in\x20the\x20document\x20-\x20which\x20due\x20to\x20floating\x0a\x20\x20\x20*\x20point\x20rendering\x20issues,\x20might\x20have\x20a\x20width\x20of\x20less\x20than\x201\x20each\x20-\x20are\x208\x0a\x20\x20\x20*\x20characters\x20wide,\x20so\x20a\x20tab\x20in\x20the\x209th\x20position\x20indents\x20properly.\x20See\x0a\x20\x20\x20*\x20https://github.com/webcompat/web-bugs/issues/17530#issuecomment-402675091\x0a\x20\x20\x20*\x20for\x20more\x20information.\x20*/\x0a\x20\x20display:\x20inline-block;\x0a\x20\x20width:\x208ch;\x0a}\x0a.search-nav\x20{\x0a\x20\x20margin-left:\x201.25rem;\x0a\x20\x20font-size:\x200.875rem;\x0a\x20\x20column-gap:\x201.25rem;\x0a\x20\x20column-fill:\x20auto;\x0a\x20\x20column-width:\x2014rem;\x0a}\x0a.search-nav\x20.indent\x20{\x0a\x20\x20margin-left:\x201.25rem;\x0a}\x0aa,\x0a.exampleHeading\x20.text,\x0a.expandAll\x20{\x0a\x20\x20color:\x20#007d9c;\x0a\x20\x20text-decoration:\x20none;\x0a}\x0aa:hover,\x0a.exampleHeading\x20.text:hover,\x0a.expandAll:hover\x20{\x0a\x20\x20text-decoration:\x20underline;\x0a}\x0a.article\x20a\x20{\x0a\x20\x20text-decoration:\x20underline;\x0a}\x0a.article\x20.title\x20a\x20{\x0a\x20\x20text-decoration:\x20none;\x0a}\x0a.permalink\x20{\x0a\x20\x20display:\x20none;\x0a}\x0a:hover\x20>\x20.permalink\x20{\x0a\x20\x20display:\x20inline;\x0a}\x0ap,\x0ali\x20{\x0a\x20\x20max-width:\x2050rem;\x0a\x20\x20word-wrap:\x20break-word;\x0a}\x0ap,\x0apre,\x0aul,\x0aol\x20{\x0a\x20\x20margin:\x201.25rem;\x0a}\x0apre\x20{\x0a\x20\x20background:\x20#efefef;\x0a\x20\x20padding:\x200.625rem;\x0a\x20\x20border-radius:\x200.3125rem;\x0a}\x0ah1,\x0ah2,\x0ah3,\x0ah4\x20{\x0a\x20\x20margin:\x201.25rem\x200\x201.25rem;\x0a\x20\x20padding:\x200;\x0a\x20\x20color:\x20#202224;\x0a\x20\x20font-family:\x20'Work\x20Sans',\x20sans-serif;\x0a\x20\x20font-weight:\x20600;\x0a}\x0ah1\x20{\x0a\x20\x20font-size:\x201.75rem;\x0a\x20\x20line-height:\x201;\x0a}\x0ah1\x20.text-muted\x20{\x0a\x20\x20color:\x20#777;\x0a}\x0ah2\x20{\x0a\x20\x20font-size:\x201.25rem;\x0a\x20\x20background:\x20#e0ebf5;\x0a\x20\x20padding:\x200.5rem;\x0a\x20\x20line-height:\x201.25;\x0a\x20\x20font-weight:\x20normal;\x0a\x20\x20overflow-wrap:\x20break-word;\x0a}\x0ah2\x20a\x20{\x0a\x20\x20font-weight:\x20bold;\x0a}\x0ah3\x20{\x0a\x20\x20font-size:\x201.25rem;\x0a\x20\x20line-height:\x201.25;\x0a\x20\x20overflow-wrap:\x20break-word;\x0a}\x0ah3,\x0ah4\x20{\x0a\x20\x20margin:\x201.25rem\x200.3125rem;\x0a}\x0ah4\x20{\x0a\x20\x20font-size:\x201rem;\x0a}\x0ah2\x20>\x20span,\x0ah3\x20>\x20span\x20{\x0a\x20\x20float:\x20right;\x0a\x20\x20margin:\x200\x2025px\x200\x200;\x0a\x20\x20font-weight:\x20normal;\x0a\x20\x20color:\x20#5279c7;\x0a}\x0adl\x20{\x0a\x20\x20margin:\x201.25rem;\x0a}\x0add\x20{\x0a\x20\x20margin:\x200\x200\x200\x201.25rem;\x0a}\x0adl,\x0add\x20{\x0a\x20\x20font-size:\x200.875rem;\x0a}\x0adiv#nav\x20table\x20td\x20{\x0a\x20\x20vertical-align:\x20top;\x0a}\x0a.ModTable\x20{\x0a\x20\x20border-collapse:\x20collapse;\x0a\x20\x20margin:\x201.25rem;\x0a\x20\x20max-width:\x2050rem;\x0a}\x0a.ModTable\x20code\x20{\x0a\x20\x20white-space:\x20nowrap;\x0a}\x0a.ModTable\x20td,\x0a.ModTable\x20th\x20{\x0a\x20\x20border:\x201px\x20solid\x20#a9a9a9;\x0a\x20\x20padding:\x201rem;\x0a\x20\x20vertical-align:\x20top;\x0a}\x0a.ModTable\x20td\x20p\x20{\x0a\x20\x20margin:\x200\x200\x201rem\x200;\x0a}\x0a.ModTable\x20td\x20p:last-child\x20{\x0a\x20\x20margin-bottom:\x200;\x0a}\x0a#pkg-index\x20h3\x20{\x0a\x20\x20font-size:\x201rem;\x0a}\x0a.pkg-dir\x20{\x0a\x20\x20padding:\x200\x200.625rem;\x0a}\x0a.pkg-dir\x20table\x20{\x0a\x20\x20border-collapse:\x20collapse;\x0a\x20\x20border-spacing:\x200;\x0a}\x0a.pkg-name\x20{\x0a\x20\x20padding-right:\x200.625rem;\x0a}\x0a.alert\x20{\x0a\x20\x20color:\x20#aa0000;\x0a}\x0a#pkg-examples\x20h3\x20{\x0a\x20\x20float:\x20left;\x0a}\x0a#pkg-examples\x20dl\x20{\x0a\x20\x20clear:\x20both;\x0a}\x0a.expandAll\x20{\x0a\x20\x20cursor:\x20pointer;\x0a\x20\x20float:\x20left;\x0a\x20\x20margin:\x201.25rem\x200;\x0a}\x0a.Site\x20{\x0a\x20\x20display:\x20flex;\x0a\x20\x20flex-direction:\x20column;\x0a\x20\x20min-height:\x20100vh;\x0a}\x0a.Site-content\x20{\x0a\x20\x20flex:\x201;\x0a}\x0a#page\x20{\x0a\x20\x20width:\x20100%;\x0a}\x0a#page\x20>\x20.container,\x0a.Header-nav\x20{\x0a\x20\x20text-align:\x20left;\x0a\x20\x20margin-left:\x20auto;\x0a\x20\x20margin-right:\x20auto;\x0a\x20\x20padding:\x200\x201.25rem;\x0a}\x0a#page\x20>\x20.container,\x0a.Header-nav,\x0a.Footer\x20{\x0a\x20\x20max-width:\x2059.38rem;\x0a}\x0a#page.wide\x20>\x20.container,\x0a.Header-nav--wide,\x0a.Footer--wide\x20{\x0a\x20\x20max-width:\x20none;\x0a}\x0adiv#playground\x20.buttons\x20a\x20{\x0a\x20\x20background:\x20#375eab;\x0a\x20\x20border:\x200.0625rem\x20solid\x20#757575;\x0a\x20\x20color:\x20white;\x0a}\x0a/*\x20Style\x20download\x20button\x20on\x20doc/install\x20page\x20*/\x0aa#start\x20{\x0a\x20\x20background:\x20#e0ebf5;\x0a\x20\x20border:\x200.0625rem\x20solid\x20#375eab;\x0a\x20\x20border-radius:\x200.3125rem;\x0a\x20\x20color:\x20#222;\x0a\x20\x20display:\x20block;\x0a\x20\x20padding:\x200.625rem;\x0a\x20\x20text-align:\x20center;\x0a\x20\x20text-decoration:\x20none;\x0a}\x0aa#start\x20.big\x20{\x0a\x20\x20display:\x20block;\x0a\x20\x20font-size:\x201.25rem;\x0a\x20\x20font-weight:\x20bold;\x0a}\x0aa#start\x20.desc\x20{\x0a\x20\x20display:\x20block;\x0a\x20\x20font-size:\x200.875rem;\x0a\x20\x20font-weight:\x20normal;\x0a\x20\x20margin-top:\x200.3125rem;\x0a}\x0a.download\x20{\x0a\x20\x20width:\x209.375rem;\x0a}\x0a::-webkit-input-placeholder\x20{\x0a\x20\x20color:\x20#7f7f7f;\x0a\x20\x20opacity:\x201;\x0a}\x0a::placeholder\x20{\x0a\x20\x20color:\x20#7f7f7f;\x0a\x20\x20opacity:\x201;\x0a}\x0a.Header\x20{\x0a\x20\x20align-items:\x20center;\x0a\x20\x20box-sizing:\x20border-box;\x0a\x20\x20display:\x20flex;\x0a\x20\x20font-size:\x200.875rem;\x0a\x20\x20justify-content:\x20space-between;\x0a\x20\x20padding:\x201.375rem\x200;\x0a}\x0a.Header.is-active\x20{\x0a\x20\x20background-color:\x20#f7f9fa;\x0a}\x0a.Header-banner\x20{\x0a\x20\x20display:\x20none;\x0a}\x0a.Header-logo\x20{\x0a\x20\x20height:\x202rem;\x0a\x20\x20width:\x205.125rem;\x0a}\x0a.Header-nav\x20{\x0a\x20\x20align-items:\x20center;\x0a\x20\x20display:\x20flex;\x0a\x20\x20flex-wrap:\x20wrap;\x0a\x20\x20justify-content:\x20space-between;\x0a\x20\x20width:\x20100%;\x0a}\x0a.Header-menuButton\x20{\x0a\x20\x20background-color:\x20transparent;\x0a\x20\x20border:\x20none;\x0a\x20\x20box-sizing:\x20content-box;\x0a\x20\x20cursor:\x20pointer;\x0a\x20\x20display:\x20inline-block;\x0a\x20\x20height:\x201.313rem;\x0a\x20\x20padding:\x200.375rem;\x0a\x20\x20position:\x20relative;\x0a\x20\x20vertical-align:\x20middle;\x0a\x20\x20width:\x201.313rem;\x0a}\x0a.Header-menuButtonInner\x20{\x0a\x20\x20position:\x20relative;\x0a}\x0a.Header-menuButton::after,\x0a.Header-menuButtonInner,\x0a.Header-menuButtonInner::before,\x0a.Header-menuButtonInner::after\x20{\x0a\x20\x20background-color:\x20#3e4042;\x0a\x20\x20height:\x200.1875rem;\x0a\x20\x20transition:\x20all\x20100ms\x20ease-in;\x0a}\x0a.Header-menuButton::after\x20{\x0a\x20\x20opacity:\x200;\x0a\x20\x20top:\x200.9375rem;\x0a}\x0a.Header-menuButton::after,\x0a.Header-menuButtonInner::before,\x0a.Header-menuButtonInner::after\x20{\x0a\x20\x20content:\x20'';\x0a\x20\x20display:\x20block;\x0a\x20\x20position:\x20absolute;\x0a\x20\x20width:\x201.313rem;\x0a}\x0a.Header-menuButtonInner::before\x20{\x0a\x20\x20top:\x20-0.375rem;\x0a}\x0a.Header-menuButtonInner::after\x20{\x0a\x20\x20bottom:\x20-0.375rem;\x0a}\x0a.Header.is-active\x20.Header-menuButton::after\x20{\x0a\x20\x20opacity:\x201;\x0a\x20\x20transform:\x20rotate(-45deg);\x0a}\x0a.Header.is-active\x20.Header-menuButton\x20.Header-menuButtonInner\x20{\x0a\x20\x20transform:\x20rotate(45deg);\x0a}\x0a.Header.is-active\x20.Header-menuButton\x20.Header-menuButtonInner::before,\x0a.Header.is-active\x20.Header-menuButton\x20.Header-menuButtonInner::after\x20{\x0a\x20\x20background-color:\x20transparent;\x0a}\x0a.Header-menu\x20{\x0a\x20\x20align-items:\x20center;\x0a\x20\x20display:\x20none;\x0a\x20\x20flex-direction:\x20column;\x0a\x20\x20list-style:\x20none;\x0a\x20\x20margin:\x200;\x0a\x20\x20padding:\x200;\x0a\x20\x20width:\x20100%;\x0a}\x0a.Header.is-active\x20.Header-menu\x20{\x0a\x20\x20display:\x20flex;\x0a}\x0a.Header-menuItem:first-of-type\x20{\x0a\x20\x20/*\x20Offset\x20the\x20padding\x20of\x20the\x20inner\x20link,\x20maintaining\x20its\x20click\x20target\x20size,\x0a\x20\x20\x20\x20\x20while\x20still\x20placing\x20the\x20item\x20as\x20if\x20it\x20had\x20no\x20top\x20margin\x20or\x20padding.\x20*/\x0a\x20\x20margin-top:\x20-0.5rem;\x0a}\x0a.Header-menuItem\x20{\x0a\x20\x20display:\x20inline-flex;\x0a}\x0a.Header-menuItem,\x0a.Header-menuItem\x20a:link,\x0a.Header-menuItem\x20a:visited,\x0a.Header-menuItem--search,\x0a.HeaderSearch\x20{\x0a\x20\x20width:\x20100%;\x0a}\x0a.Header-menuItem,\x0a.Header-menuItem\x20a:link,\x0a.Header-menuItem\x20a:visited\x20{\x0a\x20\x20color:\x20#3e4042;\x0a\x20\x20text-align:\x20center;\x0a}\x0a.Header-menuItem\x20a:link,\x0a.Header-menuItem\x20a:visited\x20{\x0a\x20\x20padding:\x200.5rem\x200;\x0a}\x0a.Header-menuItem--search\x20{\x0a\x20\x20margin-top:\x200.5rem;\x0a}\x0a.HeaderSearch,\x0a.HeaderSearch-label\x20{\x0a\x20\x20display:\x20inline-block;\x0a\x20\x20position:\x20relative;\x0a}\x0a.HeaderSearch\x20{\x0a\x20\x20border:\x200.0625rem\x20solid\x20#979797;\x0a\x20\x20border-radius:\x200.1875rem;\x0a\x20\x20display:\x20inline-flex;\x0a\x20\x20overflow:\x20hidden;\x0a\x20\x20position:\x20relative;\x0a}\x0a.HeaderSearch-input\x20{\x0a\x20\x20-webkit-appearance:\x20none;\x0a\x20\x20border:\x20none;\x0a\x20\x20border-radius:\x200;\x0a\x20\x20box-sizing:\x20border-box;\x0a\x20\x20display:\x20block;\x0a\x20\x20flex:\x201;\x0a\x20\x20font:\x20inherit;\x0a\x20\x20font-size:\x2016px;\x0a\x20\x20/*\x20Prevents\x20automatic\x20zoom\x20on\x20mobile\x20devices\x20*/\x0a\x20\x20margin:\x200;\x0a\x20\x20padding:\x200.5rem;\x0a}\x0a.HeaderSearch-input::-webkit-search-decoration\x20{\x0a\x20\x20-webkit-appearance:\x20none;\x0a}\x0a.HeaderSearch-input::-moz-ui-invalid\x20{\x0a\x20\x20box-shadow:\x20unset;\x0a}\x0a.HeaderSearch-submit\x20{\x0a\x20\x20background-color:\x20#fff;\x0a\x20\x20border:\x20none;\x0a\x20\x20box-sizing:\x20border-box;\x0a\x20\x20cursor:\x20pointer;\x0a\x20\x20margin:\x200;\x0a\x20\x20padding:\x200.125rem\x200.5rem\x200\x200.55rem;\x0a\x20\x20transition:\x20background-color\x20200ms;\x0a}\x0a.HeaderSearch:focus-within\x20.HeaderSearch-submit\x20{\x0a\x20\x20background-color:\x20#e5f6fb;\x0a}\x0a.HeaderSearch-icon\x20{\x0a\x20\x20fill:\x20#757575;\x0a\x20\x20transition:\x20fill\x20200ms;\x0a}\x0a.HeaderSearch:focus-within\x20.HeaderSearch-icon\x20{\x0a\x20\x20fill:\x20#007d9c;\x0a}\x0a@media\x20only\x20screen\x20and\x20(min-width:\x2056rem)\x20{\x0a\x20\x20.Header\x20{\x0a\x20\x20\x20\x20display:\x20block;\x0a\x20\x20\x20\x20padding:\x200;\x0a\x20\x20}\x0a\x20\x20.Header-banner\x20{\x0a\x20\x20\x20\x20background-color:\x20#000;\x0a\x20\x20\x20\x20color:\x20#fff;\x0a\x20\x20\x20\x20display:\x20block;\x0a\x20\x20\x20\x20padding:\x201rem;\x0a\x20\x20}\x0a\x20\x20.Header-banner\x20a:link,\x0a\x20\x20.Header-banner\x20a:visited\x20{\x0a\x20\x20\x20\x20color:\x20#fff;\x0a\x20\x20\x20\x20text-decoration:\x20underline;\x0a\x20\x20}\x0a\x20\x20.Header-nav\x20{\x0a\x20\x20\x20\x20width:\x20auto;\x0a\x20\x20}\x0a\x20\x20.Header.is-active\x20{\x0a\x20\x20\x20\x20background-color:\x20#fff;\x0a\x20\x20}\x0a\x20\x20.Header.is-active\x20.Header-menu\x20{\x0a\x20\x20\x20\x20display:\x20block;\x0a\x20\x20}\x0a\x20\x20.Header-menuButton\x20{\x0a\x20\x20\x20\x20display:\x20none;\x0a\x20\x20}\x0a\x20\x20.Header-menu\x20{\x0a\x20\x20\x20\x20display:\x20flex;\x0a\x20\x20\x20\x20flex-direction:\x20row;\x0a\x20\x20\x20\x20width:\x20auto;\x0a\x20\x20}\x0a\x20\x20.Header-menuItem:first-of-type\x20{\x0a\x20\x20\x20\x20margin-top:\x200;\x0a\x20\x20}\x0a\x20\x20.Header-menuItem,\x0a\x20\x20.Header-menuItem\x20a:link,\x0a\x20\x20.Header-menuItem\x20a:visited\x20{\x0a\x20\x20\x20\x20width:\x20auto;\x0a\x20\x20}\x0a\x20\x20.Header-menuItem\x20a:link,\x0a\x20\x20.Header-menuItem\x20a:visited\x20{\x0a\x20\x20\x20\x20padding:\x202rem\x201.5rem;\x0a\x20\x20}\x0a\x20\x20.Header-menuItem\x20a:hover,\x0a\x20\x20.Header-menuItem\x20a:focus\x20{\x0a\x20\x20\x20\x20text-decoration:\x20underline;\x0a\x20\x20}\x0a\x20\x20.Header-menuItem--search,\x0a\x20\x20.HeaderSearch\x20{\x0a\x20\x20\x20\x20width:\x208.75rem;\x0a\x20\x20}\x0a\x20\x20.Header-menuItem--search\x20{\x0a\x20\x20\x20\x20margin-left:\x201.5rem;\x0a\x20\x20\x20\x20margin-top:\x200;\x0a\x20\x20}\x0a\x20\x20.HeaderSearch-input\x20{\x0a\x20\x20\x20\x20min-width:\x205.625rem;\x0a\x20\x20}\x0a\x20\x20.HeaderSearch-submit\x20{\x0a\x20\x20\x20\x20padding:\x200.125rem\x200.5rem\x200;\x0a\x20\x20}\x0a}\x0a@media\x20only\x20screen\x20and\x20(min-width:\x2057.5rem)\x20{\x0a\x20\x20.Header\x20{\x0a\x20\x20\x20\x20font-size:\x201rem;\x0a\x20\x20}\x0a}\x0a.Button,\x0a.Button:link,\x0a.Button:visited\x20{\x0a\x20\x20align-items:\x20center;\x0a\x20\x20background-color:\x20#f7f9fa;\x0a\x20\x20border:\x20none;\x0a\x20\x20border-radius:\x200.1875rem;\x0a\x20\x20box-shadow:\x200\x202px\x205px\x20rgba(0,\x200,\x200,\x200.2);\x0a\x20\x20box-sizing:\x20border-box;\x0a\x20\x20color:\x20#007d9c;\x0a\x20\x20cursor:\x20pointer;\x0a\x20\x20display:\x20inline-flex;\x0a\x20\x20font:\x20bold\x200.875rem\x20Roboto,\x20sans-serif;\x0a\x20\x20height:\x202.375rem;\x0a\x20\x20padding:\x200\x200.625rem;\x0a\x20\x20justify-content:\x20center;\x0a\x20\x20min-width:\x204.063rem;\x0a\x20\x20text-decoration:\x20none;\x0a}\x0a.Button:active\x20{\x0a\x20\x20box-shadow:\x200\x201px\x203px\x20rgba(0,\x200,\x200,\x200.2);\x0a}\x0a.Button--primary,\x0a.Button--primary:link,\x0a.Button--primary:visited\x20{\x0a\x20\x20border:\x200.0625rem\x20solid\x20#00add8;\x0a}\x0a.Button--big,\x0a.Button--big:link,\x0a.Button--big:visited\x20{\x0a\x20\x20background-color:\x20#7fd5ea;\x0a\x20\x20border-radius:\x200.3125rem;\x0a\x20\x20color:\x20#202224;\x0a\x20\x20font-size:\x201.5rem;\x0a\x20\x20height:\x204rem;\x0a\x20\x20justify-content:\x20center;\x0a}\x0a.HomeContainer\x20{\x0a\x20\x20align-items:\x20top;\x0a\x20\x20display:\x20flex;\x0a\x20\x20flex-wrap:\x20wrap;\x0a\x20\x20justify-content:\x20space-between;\x0a}\x0a.HomeContainer\x20*\x20{\x0a\x20\x20box-sizing:\x20border-box;\x0a}\x0a.HomeSection\x20{\x0a\x20\x20flex:\x200\x200\x20100%;\x0a\x20\x20margin-bottom:\x202.5rem;\x0a\x20\x20padding:\x200\x201rem;\x0a}\x0a.HomeSection-header\x20{\x0a\x20\x20background:\x20none;\x0a\x20\x20color:\x20#202224;\x0a\x20\x20margin:\x200\x200\x200.625rem\x200;\x0a\x20\x20padding:\x200;\x0a\x20\x20font-weight:\x20bold;\x0a}\x0a.Hero-header\x20{\x0a\x20\x20font:\x201.5rem\x20Roboto,\x20sans-serif;\x0a\x20\x20line-height:\x20inherit;\x0a\x20\x20margin:\x200\x200\x201.875rem;\x0a}\x0a.Hero-gopher\x20{\x0a\x20\x20background:\x20url('/lib/godoc/images/home-gopher.png')\x20no-repeat;\x0a\x20\x20background-position:\x20center\x20top;\x0a\x20\x20display:\x20block;\x0a\x20\x20height:\x209.688rem;\x0a\x20\x20max-height:\x20200px;\x0a\x20\x20/*\x20Setting\x20in\x20px\x20to\x20prevent\x20the\x20gopher\x20from\x20blowing\x20up\x20in\x20very\x20high\x20default\x20font-sizes\x20*/\x0a}\x0a.HeroDownloadButton,\x0a.Hero-description\x20{\x0a\x20\x20text-align:\x20center;\x0a}\x0a.HeroDownloadButton,\x0a.HeroDownloadButton:link,\x0a.HeroDownloadButton:visited\x20{\x0a\x20\x20display:\x20flex;\x0a\x20\x20margin-bottom:\x200.5rem;\x0a}\x0a.HeroDownloadButton-image\x20{\x0a\x20\x20height:\x202rem;\x0a\x20\x20margin-right:\x202rem;\x0a\x20\x20width:\x202rem;\x0a}\x0a.Hero-description\x20{\x0a\x20\x20color:\x20#616161;\x0a\x20\x20font-size:\x200.875rem;\x0a\x20\x20margin:\x200;\x0a}\x0a@media\x20only\x20screen\x20and\x20(min-width:\x2057.1875rem)\x20{\x0a\x20\x20.HomeSection\x20{\x0a\x20\x20\x20\x20flex:\x200\x200\x2026.875rem;\x0a\x20\x20\x20\x20padding:\x200;\x0a\x20\x20}\x0a\x20\x20.Hero,\x0a\x20\x20.Playground\x20{\x0a\x20\x20\x20\x20margin-top:\x201rem;\x0a\x20\x20}\x0a}\x0a.Playground-headerContainer\x20{\x0a\x20\x20align-items:\x20baseline;\x0a\x20\x20display:\x20flex;\x0a\x20\x20justify-content:\x20space-between;\x0a}\x0a.Playground-popout\x20{\x0a\x20\x20background:\x20url('/lib/godoc/images/play-link.svg')\x20no-repeat;\x0a\x20\x20background-position:\x20right\x20center;\x0a\x20\x20cursor:\x20pointer;\x0a\x20\x20display:\x20block;\x0a\x20\x20font-size:\x201rem;\x0a\x20\x20padding:\x200\x201.688rem;\x0a}\x0a.Playground-input,\x0a.Playground-output\x20{\x0a\x20\x20padding:\x200;\x0a\x20\x20margin:\x200;\x0a\x20\x20font-family:\x20Menlo,\x20monospace;\x0a\x20\x20font-size:\x200.875rem;\x0a}\x0a.Playground-inputContainer\x20{\x0a\x20\x20border-top-left-radius:\x200.3125rem;\x0a\x20\x20border-top-right-radius:\x200.3125rem;\x0a\x20\x20overflow:\x20hidden;\x0a\x20\x20height:\x2011rem;\x0a}\x0a.Playground-input\x20{\x0a\x20\x20width:\x20100%;\x0a\x20\x20height:\x20100%;\x0a\x20\x20border:\x20none;\x0a\x20\x20outline:\x20none;\x0a\x20\x20resize:\x20none;\x0a\x20\x20padding:\x200.625rem;\x0a}\x0a.Playground-outputContainer\x20{\x0a\x20\x20border-bottom-right-radius:\x200.3125rem;\x0a\x20\x20border-bottom-left-radius:\x200.3125rem;\x0a\x20\x20border-top:\x20none\x20!important;\x0a\x20\x20padding:\x200.625rem;\x0a\x20\x20height:\x205rem;\x0a\x20\x20margin-bottom:\x201rem;\x0a\x20\x20overflow:\x20auto;\x0a}\x0a.Playground-output\x20{\x0a\x20\x20padding:\x200;\x0a\x20\x20border-radius:\x200;\x0a}\x0a.Playground-inputContainer,\x0a.Playground-input,\x0a.Playground-outputContainer,\x0a.Playground-output\x20{\x0a\x20\x20background:\x20#f7f9fa;\x0a\x20\x20color:\x20#202224;\x0a}\x0a.Playground-inputContainer,\x0a.Playground-outputContainer\x20{\x0a\x20\x20border:\x200.0625rem\x20solid\x20#c0c2c3;\x0a}\x0a.Playground-controls\x20{\x0a\x20\x20display:\x20flex;\x0a\x20\x20flex-wrap:\x20wrap;\x0a}\x0a.Playground-buttons\x20{\x0a\x20\x20display:\x20flex;\x0a\x20\x20flex:\x201;\x0a\x20\x20flex-wrap:\x20nowrap;\x0a\x20\x20justify-content:\x20space-between;\x0a}\x0a.Playground-selectExample\x20{\x0a\x20\x20background-color:\x20white;\x0a\x20\x20border-radius:\x203px;\x0a\x20\x20border:\x200.0625rem\x20solid\x20#979797;\x0a\x20\x20color:\x20inherit;\x0a\x20\x20font-family:\x20inherit;\x0a\x20\x20font-size:\x2016px;\x0a\x20\x20/*\x20Prevents\x20automatic\x20zoom\x20on\x20mobile\x20devices\x20*/\x0a\x20\x20height:\x202.375rem;\x0a\x20\x20margin:\x200\x200\x200.5rem\x200;\x0a\x20\x20width:\x20100%;\x0a}\x0a.Playground-secondaryButtons\x20{\x0a\x20\x20white-space:\x20nowrap;\x0a}\x0a.Playground-secondaryButtons\x20.Button:not(:first-child)\x20{\x0a\x20\x20margin-left:\x200.4375rem;\x0a}\x0a@media\x20only\x20screen\x20and\x20(min-width:\x2027.8125rem)\x20{\x0a\x20\x20.Playground-outputContainer\x20{\x0a\x20\x20\x20\x20margin-bottom:\x201.688rem;\x0a\x20\x20}\x0a\x20\x20.Playground-controls\x20{\x0a\x20\x20\x20\x20flex-wrap:\x20nowrap;\x0a\x20\x20}\x0a\x20\x20.Playground-selectExample\x20{\x0a\x20\x20\x20\x20margin:\x200\x200.4375rem\x200\x200;\x0a\x20\x20\x20\x20width:\x20auto;\x0a\x20\x20}\x0a}\x0a.Blog-title\x20{\x0a\x20\x20display:\x20block;\x0a\x20\x20font-size:\x201.25rem;\x0a\x20\x20font-weight:\x20normal;\x0a\x20\x20margin:\x200;\x0a}\x0a.Blog-title,\x0a.Blog-extract,\x0a.Blog-when\x20{\x0a\x20\x20margin-bottom:\x200.625rem;\x0a}\x0a.Blog-when\x20{\x0a\x20\x20color:\x20#666;\x0a\x20\x20font-size:\x200.875rem;\x0a}\x0a.Blog-footer\x20{\x0a\x20\x20text-align:\x20right;\x0a}\x0a@supports\x20(--c:\x200)\x20{\x0a\x20\x20[style*='--aspect-ratio-padding:']\x20{\x0a\x20\x20\x20\x20position:\x20relative;\x0a\x20\x20\x20\x20overflow:\x20hidden;\x0a\x20\x20\x20\x20padding-top:\x20var(--aspect-ratio-padding);\x0a\x20\x20}\x0a\x20\x20[style*='--aspect-ratio-padding:']\x20>\x20*\x20{\x0a\x20\x20\x20\x20position:\x20absolute;\x0a\x20\x20\x20\x20top:\x200;\x0a\x20\x20\x20\x20left:\x200;\x0a\x20\x20\x20\x20width:\x20100%;\x0a\x20\x20\x20\x20height:\x20100%;\x0a\x20\x20}\x0a}\x0a.Footer\x20{\x0a\x20\x20margin:\x202rem\x20auto\x200;\x0a\x20\x20padding:\x201rem\x201.25rem;\x0a\x20\x20position:\x20relative;\x0a\x20\x20text-align:\x20right;\x0a}\x0a.Footer-gopher\x20{\x0a\x20\x20bottom:\x200;\x0a\x20\x20left:\x201.25rem;\x0a\x20\x20position:\x20absolute;\x0a\x20\x20width:\x205rem;\x0a}\x0a.Footer-links\x20{\x0a\x20\x20flex:\x201;\x0a\x20\x20list-style:\x20none;\x0a\x20\x20margin:\x200;\x0a\x20\x20padding:\x200;\x0a}\x0a.Footer-link\x20{\x0a\x20\x20font-size:\x200.875rem;\x0a\x20\x20white-space:\x20nowrap;\x0a}\x0a.Footer-link\x20+\x20.Footer-link\x20{\x0a\x20\x20margin-top:\x200.5rem;\x0a}\x0a.Footer-supportedBy\x20{\x0a\x20\x20color:\x20#6e7072;\x0a\x20\x20display:\x20inline-block;\x0a\x20\x20font:\x200.875rem\x20'Product\x20Sans',\x20'Roboto',\x20'sans-serif';\x0a\x20\x20margin-top:\x201rem;\x0a}\x0a.Footer-supportedBy:hover\x20{\x0a\x20\x20text-decoration:\x20none;\x0a}\x0a@media\x20only\x20screen\x20and\x20(min-width:\x2050rem)\x20{\x0a\x20\x20.Footer\x20{\x0a\x20\x20\x20\x20align-items:\x20center;\x0a\x20\x20\x20\x20display:\x20flex;\x0a\x20\x20\x20\x20margin:\x205rem\x20auto\x200;\x0a\x20\x20}\x0a\x20\x20.Footer-links\x20{\x0a\x20\x20\x20\x20padding-left:\x206.25rem;\x0a\x20\x20\x20\x20text-align:\x20left;\x0a\x20\x20}\x0a\x20\x20.Footer-link\x20{\x0a\x20\x20\x20\x20display:\x20inline;\x0a\x20\x20}\x0a\x20\x20.Footer-link\x20+\x20.Footer-link\x20{\x0a\x20\x20\x20\x20border-left:\x200.0625rem\x20solid\x20#3e4042;\x0a\x20\x20\x20\x20margin-left:\x200.75rem;\x0a\x20\x20\x20\x20padding-left:\x200.75rem;\x0a\x20\x20}\x0a\x20\x20.Footer-supportedBy\x20{\x0a\x20\x20\x20\x20margin-top:\x200;\x0a\x20\x20}\x0a}\x0a.toggleButton\x20{\x0a\x20\x20cursor:\x20pointer;\x0a}\x0a.toggle\x20>\x20.collapsed\x20{\x0a\x20\x20display:\x20block;\x0a}\x0a.toggle\x20>\x20.expanded\x20{\x0a\x20\x20display:\x20none;\x0a}\x0a.toggleVisible\x20>\x20.collapsed\x20{\x0a\x20\x20display:\x20none;\x0a}\x0a.toggleVisible\x20>\x20.expanded\x20{\x0a\x20\x20display:\x20block;\x0a}\x0atable.codetable\x20{\x0a\x20\x20margin-left:\x20auto;\x0a\x20\x20margin-right:\x20auto;\x0a\x20\x20border-style:\x20none;\x0a}\x0atable.codetable\x20td\x20{\x0a\x20\x20padding-right:\x200.625rem;\x0a}\x0ahr\x20{\x0a\x20\x20border-style:\x20none;\x0a\x20\x20border-top:\x200.0625rem\x20solid\x20black;\x0a}\x0aimg.gopher\x20{\x0a\x20\x20float:\x20right;\x0a\x20\x20margin-left:\x200.625rem;\x0a\x20\x20margin-bottom:\x200.625rem;\x0a\x20\x20z-index:\x20-1;\x0a}\x0ah2\x20{\x0a\x20\x20clear:\x20right;\x0a}\x0adiv.play\x20{\x0a\x20\x20padding:\x200\x201.25rem\x202.5rem\x201.25rem;\x0a}\x0adiv.play\x20pre,\x0adiv.play\x20textarea,\x0adiv.play\x20.lines\x20{\x0a\x20\x20padding:\x200;\x0a\x20\x20margin:\x200;\x0a\x20\x20font-family:\x20Menlo,\x20monospace;\x0a\x20\x20font-size:\x200.875rem;\x0a}\x0adiv.play\x20.input\x20{\x0a\x20\x20padding:\x200.625rem;\x0a\x20\x20margin-top:\x200.625rem;\x0a\x0a\x20\x20border-top-left-radius:\x200.3125rem;\x0a\x20\x20border-top-right-radius:\x200.3125rem;\x0a\x0a\x20\x20overflow:\x20hidden;\x0a}\x0adiv.play\x20.input\x20textarea\x20{\x0a\x20\x20width:\x20100%;\x0a\x20\x20height:\x20100%;\x0a\x20\x20border:\x20none;\x0a\x20\x20outline:\x20none;\x0a\x20\x20resize:\x20none;\x0a\x0a\x20\x20overflow:\x20hidden;\x0a}\x0adiv#playground\x20.input\x20textarea\x20{\x0a\x20\x20overflow:\x20auto;\x0a\x20\x20resize:\x20auto;\x0a}\x0adiv.play\x20.output\x20{\x0a\x20\x20border-top:\x20none\x20!important;\x0a\x0a\x20\x20padding:\x200.625rem;\x0a\x20\x20max-height:\x2012.5rem;\x0a\x20\x20overflow:\x20auto;\x0a\x0a\x20\x20border-bottom-right-radius:\x200.3125rem;\x0a\x20\x20border-bottom-left-radius:\x200.3125rem;\x0a}\x0adiv.play\x20.output\x20pre\x20{\x0a\x20\x20padding:\x200;\x0a\x20\x20border-radius:\x200;\x0a}\x0adiv.play\x20.input,\x0adiv.play\x20.input\x20textarea,\x0adiv.play\x20.output,\x0adiv.play\x20.output\x20pre\x20{\x0a\x20\x20background:\x20#f7f9fa;\x0a\x20\x20color:\x20#202224;\x0a}\x0adiv.play\x20.input,\x0adiv.play\x20.output\x20{\x0a\x20\x20border:\x200.0625rem\x20solid\x20#c0c2c3;\x0a}\x0adiv.play\x20.buttons\x20{\x0a\x20\x20float:\x20right;\x0a\x20\x20padding:\x200.625rem\x200;\x0a\x20\x20text-align:\x20right;\x0a}\x0adiv.play\x20.buttons\x20.Button\x20{\x0a\x20\x20margin-left:\x200.3125rem;\x0a}\x0a.output\x20.stderr\x20{\x0a\x20\x20color:\x20#933;\x0a}\x0a.output\x20.system\x20{\x0a\x20\x20color:\x20#999;\x0a}\x0a/*\x20drop-down\x20playground\x20*/\x0adiv#playground\x20{\x0a\x20\x20/*\x20start\x20hidden;\x20revealed\x20by\x20javascript\x20*/\x0a\x20\x20display:\x20none;\x0a}\x0adiv#playground\x20{\x0a\x20\x20position:\x20absolute;\x0a\x20\x20top:\x203.938rem;\x0a\x20\x20right:\x201.25rem;\x0a\x20\x20padding:\x200\x200.625rem\x200.625rem\x200.625rem;\x0a\x20\x20z-index:\x201;\x0a\x20\x20text-align:\x20left;\x0a\x20\x20background:\x20#e0ebf5;\x0a\x0a\x20\x20border:\x200.0625rem\x20solid\x20#b0bbc5;\x0a\x20\x20border-top:\x20none;\x0a\x0a\x20\x20border-bottom-left-radius:\x200.3125rem;\x0a\x20\x20border-bottom-right-radius:\x200.3125rem;\x0a}\x0adiv#playground\x20.code\x20{\x0a\x20\x20width:\x2032.5rem;\x0a\x20\x20height:\x2012.5rem;\x0a}\x0adiv#playground\x20.output\x20{\x0a\x20\x20height:\x206.25rem;\x0a}\x0a/*\x20Inline\x20runnable\x20snippets\x20(play.js/initPlayground)\x20*/\x0a#content\x20.code\x20pre,\x0a#content\x20.playground\x20pre,\x0a#content\x20.output\x20pre\x20{\x0a\x20\x20margin:\x200;\x0a\x20\x20padding:\x200;\x0a\x20\x20background:\x20none;\x0a\x20\x20border:\x20none;\x0a\x20\x20outline:\x200\x20solid\x20transparent;\x0a\x20\x20overflow:\x20auto;\x0a}\x0a#content\x20.playground\x20.number,\x0a#content\x20.code\x20.number\x20{\x0a\x20\x20color:\x20#999;\x0a}\x0a#content\x20.code,\x0a#content\x20.playground,\x0a#content\x20.output\x20{\x0a\x20\x20width:\x20auto;\x0a\x20\x20margin:\x201.25rem;\x0a\x20\x20padding:\x200.625rem;\x0a\x20\x20border-radius:\x200.3125rem;\x0a}\x0a#content\x20.code,\x0a#content\x20.playground\x20{\x0a\x20\x20background:\x20#e9e9e9;\x0a}\x0a#content\x20.output\x20{\x0a\x20\x20background:\x20#202020;\x0a}\x0a#content\x20.output\x20.stdout,\x0a#content\x20.output\x20pre\x20{\x0a\x20\x20color:\x20#e6e6e6;\x0a}\x0a#content\x20.output\x20.stderr,\x0a#content\x20.output\x20.error\x20{\x0a\x20\x20color:\x20rgb(244,\x2074,\x2063);\x0a}\x0a#content\x20.output\x20.system,\x0a#content\x20.output\x20.exit\x20{\x0a\x20\x20color:\x20rgb(255,\x20209,\x2077);\x0a}\x0a#content\x20.buttons\x20{\x0a\x20\x20position:\x20relative;\x0a\x20\x20float:\x20right;\x0a\x20\x20top:\x20-3.125rem;\x0a\x20\x20right:\x201.875rem;\x0a}\x0a#content\x20.output\x20.buttons\x20{\x0a\x20\x20top:\x20-3.75rem;\x0a\x20\x20right:\x200;\x0a\x20\x20height:\x200;\x0a}\x0a#content\x20.buttons\x20.kill\x20{\x0a\x20\x20display:\x20none;\x0a\x20\x20visibility:\x20hidden;\x0a}\x0aa.error\x20{\x0a\x20\x20font-weight:\x20bold;\x0a\x20\x20color:\x20white;\x0a\x20\x20background-color:\x20darkred;\x0a\x20\x20border-bottom-left-radius:\x200.25rem;\x0a\x20\x20border-bottom-right-radius:\x200.25rem;\x0a\x20\x20border-top-left-radius:\x200.25rem;\x0a\x20\x20border-top-right-radius:\x200.25rem;\x0a\x20\x20padding:\x200.125rem\x200.25rem\x200.125rem\x200.25rem;\x0a\x20\x20/*\x20TRBL\x20*/\x0a}\x0a.downloading\x20{\x0a\x20\x20background:\x20#f9f9be;\x0a\x20\x20padding:\x200.625rem;\x0a\x20\x20text-align:\x20center;\x0a\x20\x20border-radius:\x200.3125rem;\x0a}\x0a@media\x20(max-width:\x2043.75em)\x20{\x0a\x20\x20body\x20{\x0a\x20\x20\x20\x20font-size:\x200.9375rem;\x0a\x20\x20}\x0a\x20\x20div#playground\x20{\x0a\x20\x20\x20\x20left:\x200;\x0a\x20\x20\x20\x20right:\x200;\x0a\x20\x20}\x0a\x20\x20pre,\x0a\x20\x20code\x20{\x0a\x20\x20\x20\x20font-size:\x200.866rem;\x0a\x20\x20}\x0a\x20\x20#page\x20>\x20.container,\x0a\x20\x20.Header-nav\x20{\x0a\x20\x20\x20\x20padding:\x200\x200.625rem;\x0a\x20\x20}\x0a\x20\x20p,\x0a\x20\x20pre,\x0a\x20\x20ul,\x0a\x20\x20ol\x20{\x0a\x20\x20\x20\x20margin:\x200.625rem;\x0a\x20\x20}\x0a\x20\x20.pkg-synopsis\x20{\x0a\x20\x20\x20\x20display:\x20none;\x0a\x20\x20}\x0a\x20\x20img.gopher\x20{\x0a\x20\x20\x20\x20display:\x20none;\x0a\x20\x20}\x0a}\x0a@media\x20print\x20{\x0a\x20\x20pre\x20{\x0a\x20\x20\x20\x20background:\x20#fff;\x0a\x20\x20\x20\x20border:\x200.0625rem\x20solid\x20#bbb;\x0a\x20\x20\x20\x20white-space:\x20pre-wrap;\x0a\x20\x20\x20\x20page-break-inside:\x20avoid;\x0a\x20\x20}\x0a}", - "doc/mod.html": "\x0a\x0aIntroduction\x0a

Modules\x20are\x20how\x20Go\x20manages\x20dependencies.

\x0a

This\x20document\x20is\x20a\x20detailed\x20reference\x20manual\x20for\x20Go's\x20module\x20system.\x20For\x20an\x0aintroduction\x20to\x20creating\x20Go\x20projects,\x20see\x20How\x20to\x20Write\x20Go\x0aCode.\x20For\x20information\x20on\x20using\x20modules,\x0amigrating\x20projects\x20to\x20modules,\x20and\x20other\x20topics,\x20see\x20the\x20blog\x20series\x20starting\x0awith\x20Using\x20Go\x20Modules.

\x0aModules,\x20packages,\x20and\x20versions\x0a

A\x20module\x20is\x20a\x20collection\x20of\x20packages\x20that\x20are\x20released,\x20versioned,\x0aand\x20distributed\x20together.\x20Modules\x20may\x20be\x20downloaded\x20directly\x20from\x20version\x0acontrol\x20repositories\x20or\x20from\x20module\x20proxy\x20servers.

\x0a

A\x20module\x20is\x20identified\x20by\x20a\x20module\x20path,\x20which\x20is\x20declared\x0ain\x20a\x20go.mod\x20file,\x20together\x20with\x20information\x20about\x20the\x0amodule's\x20dependencies.\x20The\x20module\x20root\x20directory\x20is\x20the\x20directory\x0athat\x20contains\x20the\x20go.mod\x20file.\x20The\x20main\x20module\x20is\x20the\x20module\x0acontaining\x20the\x20directory\x20where\x20the\x20go\x20command\x20is\x20invoked.

\x0a

Each\x20package\x20within\x20a\x20module\x20is\x20a\x20collection\x20of\x20source\x20files\x20in\x20the\x0asame\x20directory\x20that\x20are\x20compiled\x20together.\x20A\x20package\x20path\x20is\x20the\x0amodule\x20path\x20joined\x20with\x20the\x20subdirectory\x20containing\x20the\x20package\x20(relative\x20to\x20the\x0amodule\x20root).\x20For\x20example,\x20the\x20module\x20"golang.org/x/net"\x20contains\x20a\x20package\x20in\x0athe\x20directory\x20"html".\x20That\x20package's\x20path\x20is\x20"golang.org/x/net/html".

\x0aModule\x20paths\x0a

A\x20module\x20path\x20is\x20the\x20canonical\x20name\x20for\x20a\x20module,\x20declared\x20with\x20the\x0amodule\x20directive\x20in\x20the\x20module's\x20go.mod\x0afile.\x20A\x20module's\x20path\x20is\x20the\x20prefix\x20for\x20package\x20paths\x20within\x0athe\x20module.

\x0a

A\x20module\x20path\x20should\x20describe\x20both\x20what\x20the\x20module\x20does\x20and\x20where\x20to\x20find\x20it.\x0aTypically,\x20a\x20module\x20path\x20consists\x20of\x20a\x20repository\x20root\x20path,\x20a\x20directory\x20within\x0athe\x20repository\x20(usually\x20empty),\x20and\x20a\x20major\x20version\x20suffix\x20(only\x20for\x20major\x0aversion\x202\x20or\x20higher).

\x0a
    \x0a
  • The\x20repository\x20root\x20path\x20is\x20the\x20portion\x20of\x20the\x20module\x20path\x20that\x0acorresponds\x20to\x20the\x20root\x20directory\x20of\x20the\x20version\x20control\x20repository\x20where\x20the\x0amodule\x20is\x20developed.\x20Most\x20modules\x20are\x20defined\x20in\x20their\x20repository's\x20root\x0adirectory,\x20so\x20this\x20is\x20usually\x20the\x20entire\x20path.\x20For\x20example,\x0agolang.org/x/net\x20is\x20the\x20repository\x20root\x20path\x20for\x20the\x20module\x20of\x20the\x20same\x0aname.\x20See\x20Finding\x20a\x20repository\x20for\x20a\x20module\x20path\x20for\x20information\x0aon\x20how\x20the\x20go\x20command\x20locates\x20a\x20repository\x20using\x20HTTP\x20requests\x20derived\x0afrom\x20a\x20module\x20path.
  • \x0a
  • If\x20the\x20module\x20is\x20not\x20defined\x20in\x20the\x20repository's\x20root\x20directory,\x20the\x0amodule\x20subdirectory\x20is\x20the\x20part\x20of\x20the\x20module\x20path\x20that\x20names\x20the\x0adirectory,\x20not\x20including\x20the\x20major\x20version\x20suffix.\x20This\x20also\x20serves\x20as\x20a\x0aprefix\x20for\x20semantic\x20version\x20tags.\x20For\x20example,\x20the\x20module\x0agolang.org/x/tools/gopls\x20is\x20in\x20the\x20gopls\x20subdirectory\x20of\x20the\x20repository\x0awith\x20root\x20path\x20golang.org/x/tools,\x20so\x20it\x20has\x20the\x20module\x20subdirectory\x0agopls.\x20See\x20Mapping\x20versions\x20to\x20commits\x20and\x20Module\x0adirectories\x20within\x20a\x20repository.
  • \x0a
  • If\x20the\x20module\x20is\x20released\x20at\x20major\x20version\x202\x20or\x20higher,\x20the\x20module\x20path\x20must\x0aend\x20with\x20a\x20major\x20version\x20suffix\x20like\x0a/v2.\x20This\x20may\x20or\x20may\x20not\x20be\x20part\x20of\x20the\x20subdirectory\x20name.\x20For\x20example,\x20the\x0amodule\x20with\x20path\x20golang.org/x/repo/sub/v2\x20could\x20be\x20in\x20the\x20/sub\x20or\x0a/sub/v2\x20subdirectory\x20of\x20the\x20repository\x20golang.org/x/repo.
  • \x0a
\x0a

If\x20a\x20module\x20might\x20be\x20depended\x20on\x20by\x20other\x20modules,\x20these\x20rules\x20must\x20be\x20followed\x0aso\x20that\x20the\x20go\x20command\x20can\x20find\x20and\x20download\x20the\x20module.\x20There\x20are\x20also\x0aseveral\x20lexical\x20restrictions\x20on\x20characters\x20allowed\x20in\x0amodule\x20paths.

\x0aVersions\x0a

A\x20version\x20identifies\x20an\x20immutable\x20snapshot\x20of\x20a\x20module,\x20which\x20may\x20be\x0aeither\x20a\x20release\x20or\x20a\x0apre-release.\x20Each\x20version\x20starts\x20with\x20the\x20letter\x0av,\x20followed\x20by\x20a\x20semantic\x20version.\x20See\x20Semantic\x20Versioning\x0a2.0.0\x20for\x20details\x20on\x20how\x20versions\x20are\x0aformatted,\x20interpreted,\x20and\x20compared.

\x0a

To\x20summarize,\x20a\x20semantic\x20version\x20consists\x20of\x20three\x20non-negative\x20integers\x20(the\x0amajor,\x20minor,\x20and\x20patch\x20versions,\x20from\x20left\x20to\x20right)\x20separated\x20by\x20dots.\x20The\x0apatch\x20version\x20may\x20be\x20followed\x20by\x20an\x20optional\x20pre-release\x20string\x20starting\x20with\x20a\x0ahyphen.\x20The\x20pre-release\x20string\x20or\x20patch\x20version\x20may\x20be\x20followed\x20by\x20a\x20build\x0ametadata\x20string\x20starting\x20with\x20a\x20plus.\x20For\x20example,\x20v0.0.0,\x20v1.12.134,\x0av8.0.5-pre,\x20and\x20v2.0.9+meta\x20are\x20valid\x20versions.

\x0a

Each\x20part\x20of\x20a\x20version\x20indicates\x20whether\x20the\x20version\x20is\x20stable\x20and\x20whether\x20it\x20is\x0acompatible\x20with\x20previous\x20versions.

\x0a
    \x0a
  • The\x20major\x20version\x20must\x20be\x20incremented\x20and\x20the\x20minor\x0aand\x20patch\x20versions\x20must\x20be\x20set\x20to\x20zero\x20after\x20a\x20backwards\x20incompatible\x20change\x0ais\x20made\x20to\x20the\x20module's\x20public\x20interface\x20or\x20documented\x20functionality,\x20for\x0aexample,\x20after\x20a\x20package\x20is\x20removed.
  • \x0a
  • The\x20minor\x20version\x20must\x20be\x20incremented\x20and\x20the\x20patch\x0aversion\x20set\x20to\x20zero\x20after\x20a\x20backwards\x20compatible\x20change,\x20for\x20example,\x20after\x20a\x0anew\x20function\x20is\x20added.
  • \x0a
  • The\x20patch\x20version\x20must\x20be\x20incremented\x20after\x20a\x20change\x0athat\x20does\x20not\x20affect\x20the\x20module's\x20public\x20interface,\x20such\x20as\x20a\x20bug\x20fix\x20or\x0aoptimization.
  • \x0a
  • The\x20pre-release\x20suffix\x20indicates\x20a\x20version\x20is\x20a\x0apre-release.\x20Pre-release\x20versions\x20sort\x20before\x0athe\x20corresponding\x20release\x20versions.\x20For\x20example,\x20v1.2.3-pre\x20comes\x20before\x0av1.2.3.
  • \x0a
  • The\x20build\x20metadata\x20suffix\x20is\x20ignored\x20for\x20the\x20purpose\x20of\x20comparing\x20versions.\x0aTags\x20with\x20build\x20metadata\x20are\x20ignored\x20in\x20version\x20control\x20repositories,\x20but\x0abuild\x20metadata\x20is\x20preserved\x20in\x20versions\x20specified\x20in\x20go.mod\x20files.\x20The\x0asuffix\x20+incompatible\x20denotes\x20a\x20version\x20released\x20before\x20migrating\x20to\x20modules\x0aversion\x20major\x20version\x202\x20or\x20later\x20(see\x20Compatibility\x20with\x20non-module\x0arepositories.
  • \x0a
\x0a

A\x20version\x20is\x20considered\x20unstable\x20if\x20its\x20major\x20version\x20is\x200\x20or\x20it\x20has\x20a\x0apre-release\x20suffix.\x20Unstable\x20versions\x20are\x20not\x20subject\x20to\x20compatibility\x0arequirements.\x20For\x20example,\x20v0.2.0\x20may\x20not\x20be\x20compatible\x20with\x20v0.1.0,\x20and\x0av1.5.0-beta\x20may\x20not\x20be\x20compatible\x20with\x20v1.5.0.

\x0a

Go\x20may\x20access\x20modules\x20in\x20version\x20control\x20systems\x20using\x20tags,\x20branches,\x20or\x0arevisions\x20that\x20don't\x20follow\x20these\x20conventions.\x20However,\x20within\x20the\x20main\x20module,\x0athe\x20go\x20command\x20will\x20automatically\x20convert\x20revision\x20names\x20that\x20don't\x20follow\x0athis\x20standard\x20into\x20canonical\x20versions.\x20The\x20go\x20command\x20will\x20also\x20remove\x20build\x0ametadata\x20suffixes\x20(except\x20for\x20+incompatible)\x20as\x20part\x20of\x20this\x20process.\x20This\x20may\x0aresult\x20in\x20a\x20pseudo-version,\x20a\x20pre-release\x20version\x20that\x0aencodes\x20a\x20revision\x20identifier\x20(such\x20as\x20a\x20Git\x20commit\x20hash)\x20and\x20a\x20timestamp\x20from\x20a\x0aversion\x20control\x20system.\x20For\x20example,\x20the\x20command\x20go\x20get\x20-d\x20golang.org/x/net@daa7c041\x20will\x20convert\x20the\x20commit\x20hash\x20daa7c041\x20into\x20the\x0apseudo-version\x20v0.0.0-20191109021931-daa7c04131f5.\x20Canonical\x20versions\x20are\x0arequired\x20outside\x20the\x20main\x20module,\x20and\x20the\x20go\x20command\x20will\x20report\x20an\x20error\x20if\x20a\x0anon-canonical\x20version\x20like\x20master\x20appears\x20in\x20a\x20go.mod\x20file.

\x0aPseudo-versions\x0a

A\x20pseudo-version\x20is\x20a\x20specially\x20formatted\x0apre-release\x20version\x20that\x20encodes\x0ainformation\x20about\x20a\x20specific\x20revision\x20in\x20a\x20version\x20control\x20repository.\x20For\x0aexample,\x20v0.0.0-20191109021931-daa7c04131f5\x20is\x20a\x20pseudo-version.

\x0a

Pseudo-versions\x20may\x20refer\x20to\x20revisions\x20for\x20which\x20no\x20semantic\x20version\x0atags\x20are\x20available.\x20They\x20may\x20be\x20used\x20to\x20test\x0acommits\x20before\x20creating\x20version\x20tags,\x20for\x20example,\x20on\x20a\x20development\x20branch.

\x0a

Each\x20pseudo-version\x20has\x20three\x20parts:

\x0a
    \x0a
  • A\x20base\x20version\x20prefix\x20(vX.0.0\x20or\x20vX.Y.Z-0),\x20which\x20is\x20either\x20derived\x20from\x20a\x0asemantic\x20version\x20tag\x20that\x20precedes\x20the\x20revision\x20or\x20vX.0.0\x20if\x20there\x20is\x20no\x0asuch\x20tag.
  • \x0a
  • A\x20timestamp\x20(yymmddhhmmss),\x20which\x20is\x20the\x20UTC\x20time\x20the\x20revision\x20was\x20created.\x0aIn\x20Git,\x20this\x20is\x20the\x20commit\x20time,\x20not\x20the\x20author\x20time.
  • \x0a
  • A\x20revision\x20identifier\x20(abcdefabcdef),\x20which\x20is\x20a\x2012-character\x20prefix\x20of\x20the\x0acommit\x20hash,\x20or\x20in\x20Subversion,\x20a\x20zero-padded\x20revision\x20number.
  • \x0a
\x0a

Each\x20pseudo-version\x20may\x20be\x20in\x20one\x20of\x20three\x20forms,\x20depending\x20on\x20the\x20base\x20version.\x0aThese\x20forms\x20ensure\x20that\x20a\x20pseudo-version\x20compares\x20higher\x20than\x20its\x20base\x20version,\x0abut\x20lower\x20than\x20the\x20next\x20tagged\x20version.

\x0a
    \x0a
  • vX.0.0-yyyymmddhhmmss-abcdefabcdef\x20is\x20used\x20when\x20there\x20is\x20no\x20known\x20base\x0aversion.\x20As\x20with\x20all\x20versions,\x20the\x20major\x20version\x20X\x20must\x20match\x20the\x20module's\x0amajor\x20version\x20suffix.
  • \x0a
  • vX.Y.Z-pre.0.yyyymmddhhmmss-abcdefabcdef\x20is\x20used\x20when\x20the\x20base\x20version\x20is\x0aa\x20pre-release\x20version\x20like\x20vX.Y.Z-pre.
  • \x0a
  • vX.Y.(Z+1)-0.yyyymmddhhmmss-abcdefabcdef\x20is\x20used\x20when\x20the\x20base\x20version\x20is\x0aa\x20release\x20version\x20like\x20vX.Y.Z.\x20For\x20example,\x20if\x20the\x20base\x20version\x20is\x0av1.2.3,\x20a\x20pseudo-version\x20might\x20be\x20v1.2.4-0.20191109021931-daa7c04131f5.
  • \x0a
\x0a

More\x20than\x20one\x20pseudo-version\x20may\x20refer\x20to\x20the\x20same\x20commit\x20by\x20using\x20different\x0abase\x20versions.\x20This\x20happens\x20naturally\x20when\x20a\x20lower\x20version\x20is\x20tagged\x20after\x20a\x0apseudo-version\x20is\x20written.

\x0a

These\x20forms\x20give\x20pseudo-versions\x20two\x20useful\x20properties:

\x0a
    \x0a
  • Pseudo-versions\x20with\x20known\x20base\x20versions\x20sort\x20higher\x20than\x20those\x20versions\x20but\x0alower\x20than\x20other\x20pre-release\x20for\x20later\x20versions.
  • \x0a
  • Pseudo-versions\x20with\x20the\x20same\x20base\x20version\x20prefix\x20sort\x20chronologically.
  • \x0a
\x0a

The\x20go\x20command\x20performs\x20several\x20checks\x20to\x20ensure\x20that\x20module\x20authors\x20have\x0acontrol\x20over\x20how\x20pseudo-versions\x20are\x20compared\x20with\x20other\x20versions\x20and\x20that\x0apseudo-versions\x20refer\x20to\x20revisions\x20that\x20are\x20actually\x20part\x20of\x20a\x20module's\x0acommit\x20history.

\x0a
    \x0a
  • If\x20a\x20base\x20version\x20is\x20specified,\x20there\x20must\x20be\x20a\x20corresponding\x20semantic\x20version\x0atag\x20that\x20is\x20an\x20ancestor\x20of\x20the\x20revision\x20described\x20by\x20the\x20pseudo-version.\x20This\x0aprevents\x20developers\x20from\x20bypassing\x20minimal\x20version\x0aselection\x20using\x20a\x20pseudo-version\x20that\x0acompares\x20higher\x20than\x20all\x20tagged\x20versions\x20like\x0av1.999.999-99999999999999-daa7c04131f5.
  • \x0a
  • The\x20timestamp\x20must\x20match\x20the\x20revision's\x20timestamp.\x20This\x20prevents\x20attackers\x0afrom\x20flooding\x20module\x20proxies\x20with\x20an\x20unbounded\x20number\x0aof\x20otherwise\x20identical\x20pseudo-versions.\x20This\x20also\x20prevents\x20module\x20consumers\x0afrom\x20changing\x20the\x20relative\x20ordering\x20of\x20versions.
  • \x0a
  • The\x20revision\x20must\x20be\x20an\x20ancestor\x20of\x20one\x20of\x20the\x20module\x20repository's\x20branches\x20or\x0atags.\x20This\x20prevents\x20attackers\x20from\x20referring\x20to\x20unapproved\x20changes\x20or\x20pull\x0arequests.
  • \x0a
\x0a

Pseudo-versions\x20never\x20need\x20to\x20be\x20typed\x20by\x20hand.\x20Many\x20commands\x20accept\x0aa\x20commit\x20hash\x20or\x20a\x20branch\x20name\x20and\x20will\x20translate\x20it\x20into\x20a\x20pseudo-version\x0a(or\x20tagged\x20version\x20if\x20available)\x20automatically.\x20For\x20example:

\x0a
go\x20get\x20-d\x20example.com/mod@master\x0ago\x20list\x20-m\x20-json\x20example.com/mod@abcd1234\x0a
\x0aMajor\x20version\x20suffixes\x0a

Starting\x20with\x20major\x20version\x202,\x20module\x20paths\x20must\x20have\x20a\x20major\x20version\x0asuffix\x20like\x20/v2\x20that\x20matches\x20the\x20major\x20version.\x20For\x20example,\x20if\x20a\x20module\x0ahas\x20the\x20path\x20example.com/mod\x20at\x20v1.0.0,\x20it\x20must\x20have\x20the\x20path\x0aexample.com/mod/v2\x20at\x20version\x20v2.0.0.

\x0a

Major\x20version\x20suffixes\x20implement\x20the\x20import\x20compatibility\x0arule:

\x0a
\x0a

If\x20an\x20old\x20package\x20and\x20a\x20new\x20package\x20have\x20the\x20same\x20import\x20path,\x0athe\x20new\x20package\x20must\x20be\x20backwards\x20compatible\x20with\x20the\x20old\x20package.

\x0a
\x0a

By\x20definition,\x20packages\x20in\x20a\x20new\x20major\x20version\x20of\x20a\x20module\x20are\x20not\x20backwards\x0acompatible\x20with\x20the\x20corresponding\x20packages\x20in\x20the\x20previous\x20major\x20version.\x0aConsequently,\x20starting\x20with\x20v2,\x20packages\x20need\x20new\x20import\x20paths.\x20This\x20is\x0aaccomplished\x20by\x20adding\x20a\x20major\x20version\x20suffix\x20to\x20the\x20module\x20path.\x20Since\x20the\x0amodule\x20path\x20is\x20a\x20prefix\x20of\x20the\x20import\x20path\x20for\x20each\x20package\x20within\x20the\x20module,\x0aadding\x20the\x20major\x20version\x20suffix\x20to\x20the\x20module\x20path\x20provides\x20a\x20distinct\x20import\x0apath\x20for\x20each\x20incompatible\x20version.

\x0a

Major\x20version\x20suffixes\x20are\x20not\x20allowed\x20at\x20major\x20versions\x20v0\x20or\x20v1.\x20There\x20is\x0ano\x20need\x20to\x20change\x20the\x20module\x20path\x20between\x20v0\x20and\x20v1\x20because\x20v0\x20versions\x0aare\x20unstable\x20and\x20have\x20no\x20compatibility\x20guarantee.\x20Additionally,\x20for\x20most\x0amodules,\x20v1\x20is\x20backwards\x20compatible\x20with\x20the\x20last\x20v0\x20version;\x20a\x20v1\x20version\x0aacts\x20as\x20a\x20commitment\x20to\x20compatibility,\x20rather\x20than\x20an\x20indication\x20of\x0aincompatible\x20changes\x20compared\x20with\x20v0.

\x0a

As\x20a\x20special\x20case,\x20modules\x20paths\x20starting\x20with\x20gopkg.in/\x20must\x20always\x20have\x20a\x0amajor\x20version\x20suffix,\x20even\x20at\x20v0\x20and\x20v1.\x20The\x20suffix\x20must\x20start\x20with\x20a\x20dot\x0arather\x20than\x20a\x20slash\x20(for\x20example,\x20gopkg.in/yaml.v2).

\x0a

Major\x20version\x20suffixes\x20let\x20multiple\x20major\x20versions\x20of\x20a\x20module\x20coexist\x20in\x20the\x0asame\x20build.\x20This\x20may\x20be\x20necessary\x20due\x20to\x20a\x20diamond\x20dependency\x0aproblem.\x20Ordinarily,\x20if\x0aa\x20module\x20is\x20required\x20at\x20two\x20different\x20versions\x20by\x20transitive\x20dependencies,\x20the\x0ahigher\x20version\x20will\x20be\x20used.\x20However,\x20if\x20the\x20two\x20versions\x20are\x20incompatible,\x0aneither\x20version\x20will\x20satisfy\x20all\x20clients.\x20Since\x20incompatible\x20versions\x20must\x20have\x0adifferent\x20major\x20version\x20numbers,\x20they\x20must\x20also\x20have\x20different\x20module\x20paths\x20due\x0ato\x20major\x20version\x20suffixes.\x20This\x20resolves\x20the\x20conflict:\x20modules\x20with\x20distinct\x0asuffixes\x20are\x20treated\x20as\x20separate\x20modules,\x20and\x20their\x20packages\xe2\x80\x94even\x20packages\x20in\x0asame\x20subdirectory\x20relative\x20to\x20their\x20module\x20roots\xe2\x80\x94are\x20distinct.

\x0a

Many\x20Go\x20projects\x20released\x20versions\x20at\x20v2\x20or\x20higher\x20without\x20using\x20a\x20major\x0aversion\x20suffix\x20before\x20migrating\x20to\x20modules\x20(perhaps\x20before\x20modules\x20were\x20even\x0aintroduced).\x20These\x20versions\x20are\x20annotated\x20with\x20a\x20+incompatible\x20build\x20tag\x20(for\x0aexample,\x20v2.0.0+incompatible).\x20See\x20Compatibility\x20with\x20non-module\x0arepositories\x20for\x20more\x20information.

\x0aResolving\x20a\x20package\x20to\x20a\x20module\x0a

When\x20the\x20go\x20command\x20loads\x20a\x20package\x20using\x20a\x20package\x0apath,\x20it\x20needs\x20to\x20determine\x20which\x20module\x20provides\x20the\x0apackage.

\x0a

The\x20go\x20command\x20starts\x20by\x20searching\x20the\x20build\x20list\x20for\x0amodules\x20with\x20paths\x20that\x20are\x20prefixes\x20of\x20the\x20package\x20path.\x20For\x20example,\x20if\x20the\x0apackage\x20example.com/a/b\x20is\x20imported,\x20and\x20the\x20module\x20example.com/a\x20is\x20in\x20the\x0abuild\x20list,\x20the\x20go\x20command\x20will\x20check\x20whether\x20example.com/a\x20contains\x20the\x0apackage,\x20in\x20the\x20directory\x20b.\x20At\x20least\x20one\x20file\x20with\x20the\x20.go\x20extension\x20must\x0abe\x20present\x20in\x20a\x20directory\x20for\x20it\x20to\x20be\x20considered\x20a\x20package.\x20Build\x0aconstraints\x20are\x20not\x20applied\x20for\x20this\x0apurpose.\x20If\x20exactly\x20one\x20module\x20in\x20the\x20build\x20list\x20provides\x20the\x20package,\x20that\x0amodule\x20is\x20used.\x20If\x20two\x20or\x20more\x20modules\x20provide\x20the\x20package,\x20an\x20error\x20is\x0areported.\x20If\x20no\x20modules\x20provide\x20the\x20package,\x20the\x20go\x20command\x20will\x20attempt\x20to\x0afind\x20a\x20new\x20module\x20(unless\x20the\x20flags\x20-mod=readonly\x20or\x20-mod=vendor\x20are\x20used,\x0ain\x20which\x20case,\x20an\x20error\x20is\x20reported).

\x0a\x0a

When\x20the\x20go\x20command\x20looks\x20up\x20a\x20new\x20module\x20for\x20a\x20package\x20path,\x20it\x20checks\x20the\x0aGOPROXY\x20environment\x20variable,\x20which\x20is\x20a\x20comma-separated\x20list\x20of\x20proxy\x20URLs\x20or\x0athe\x20keywords\x20direct\x20or\x20off.\x20A\x20proxy\x20URL\x20indicates\x20the\x20go\x20command\x20should\x0acontact\x20a\x20module\x20proxy\x20using\x20the\x20GOPROXY\x0aprotocol.\x20direct\x20indicates\x20that\x20the\x20go\x20command\x20should\x0acommunicate\x20with\x20a\x20version\x20control\x20system.\x20off\x20indicates\x20that\x20no\x0acommunication\x20should\x20be\x20attempted.\x20The\x20GOPRIVATE\x20and\x20GONOPROXY\x20environment\x0avariables\x20can\x20also\x20be\x20used\x20to\x20control\x20this\x20behavior.

\x0a

For\x20each\x20entry\x20in\x20the\x20GOPROXY\x20list,\x20the\x20go\x20command\x20requests\x20the\x20latest\x0aversion\x20of\x20each\x20module\x20path\x20that\x20might\x20provide\x20the\x20package\x20(that\x20is,\x20each\x20prefix\x0aof\x20the\x20package\x20path).\x20For\x20each\x20successfully\x20requested\x20module\x20path,\x20the\x20go\x0acommand\x20will\x20download\x20the\x20module\x20at\x20the\x20latest\x20version\x20and\x20check\x20whether\x20the\x0amodule\x20contains\x20the\x20requested\x20package.\x20If\x20one\x20or\x20more\x20modules\x20contain\x20the\x0arequested\x20package,\x20the\x20module\x20with\x20the\x20longest\x20path\x20is\x20used.\x20If\x20one\x20or\x20more\x0amodules\x20are\x20found\x20but\x20none\x20contain\x20the\x20requested\x20package,\x20an\x20error\x20is\x0areported.\x20If\x20no\x20modules\x20are\x20found,\x20the\x20go\x20command\x20tries\x20the\x20next\x20entry\x20in\x20the\x0aGOPROXY\x20list.\x20If\x20no\x20entries\x20are\x20left,\x20an\x20error\x20is\x20reported.

\x0a

For\x20example,\x20suppose\x20the\x20go\x20command\x20is\x20looking\x20for\x20a\x20module\x20that\x20provides\x20the\x0apackage\x20golang.org/x/net/html,\x20and\x20GOPROXY\x20is\x20set\x20to\x0ahttps://corp.example.com,https://proxy.golang.org.\x20The\x20go\x20command\x20may\x20make\x0athe\x20following\x20requests:

\x0a
    \x0a
  • To\x20https://corp.example.com/\x20(in\x20parallel):\x0a
      \x0a
    • Request\x20for\x20latest\x20version\x20of\x20golang.org/x/net/html
    • \x0a
    • Request\x20for\x20latest\x20version\x20of\x20golang.org/x/net
    • \x0a
    • Request\x20for\x20latest\x20version\x20of\x20golang.org/x
    • \x0a
    • Request\x20for\x20latest\x20version\x20of\x20golang.org
    • \x0a
    \x0a
  • \x0a
  • To\x20https://proxy.golang.org/,\x20if\x20all\x20requests\x20to\x20https://corp.example.com/\x0ahave\x20failed\x20with\x20404\x20or\x20410:\x0a
      \x0a
    • Request\x20for\x20latest\x20version\x20of\x20golang.org/x/net/html
    • \x0a
    • Request\x20for\x20latest\x20version\x20of\x20golang.org/x/net
    • \x0a
    • Request\x20for\x20latest\x20version\x20of\x20golang.org/x
    • \x0a
    • Request\x20for\x20latest\x20version\x20of\x20golang.org
    • \x0a
    \x0a
  • \x0a
\x0a

After\x20a\x20suitable\x20module\x20has\x20been\x20found,\x20the\x20go\x20command\x20will\x20add\x20a\x20new\x0arequirement\x20with\x20the\x20new\x20module's\x20path\x20and\x20version\x20to\x20the\x0amain\x20module's\x20go.mod\x20file.\x20This\x20ensures\x20that\x20when\x20the\x20same\x20package\x20is\x20loaded\x0ain\x20the\x20future,\x20the\x20same\x20module\x20will\x20be\x20used\x20at\x20the\x20same\x20version.\x20If\x20the\x20resolved\x0apackage\x20is\x20not\x20imported\x20by\x20a\x20package\x20in\x20the\x20main\x20module,\x20the\x20new\x20requirement\x0awill\x20have\x20an\x20//\x20indirect\x20comment.

\x0ago.mod\x20files\x0a

A\x20module\x20is\x20defined\x20by\x20a\x20UTF-8\x20encoded\x20text\x20file\x20named\x20go.mod\x20in\x20its\x20root\x0adirectory.\x20The\x20go.mod\x20file\x20is\x20line-oriented.\x20Each\x20line\x20holds\x20a\x20single\x0adirective,\x20made\x20up\x20of\x20a\x20keyword\x20followed\x20by\x20arguments.\x20For\x20example:

\x0a
module\x20example.com/my/thing\x0a\x0ago\x201.12\x0a\x0arequire\x20example.com/other/thing\x20v1.0.2\x0arequire\x20example.com/new/thing/v2\x20v2.3.4\x0aexclude\x20example.com/old/thing\x20v1.2.3\x0areplace\x20example.com/bad/thing\x20v1.4.5\x20=>\x20example.com/good/thing\x20v1.4.5\x0a
\x0a

The\x20leading\x20keyword\x20can\x20be\x20factored\x20out\x20of\x20adjacent\x20lines\x20to\x20create\x20a\x20block,\x0alike\x20in\x20Go\x20imports.

\x0a
require\x20(\x0a\x20\x20\x20\x20example.com/new/thing/v2\x20v2.3.4\x0a\x20\x20\x20\x20example.com/old/thing\x20v1.2.3\x0a)\x0a
\x0a

The\x20go.mod\x20file\x20is\x20designed\x20to\x20be\x20human\x20readable\x20and\x20machine\x20writable.\x20The\x0ago\x20command\x20provides\x20several\x20subcommands\x20that\x20change\x20go.mod\x20files.\x20For\x0aexample,\x20go\x20get\x20can\x20upgrade\x20or\x20downgrade\x20specific\x20dependencies.\x0aCommands\x20that\x20load\x20the\x20module\x20graph\x20will\x20automatically\x20update\x0ago.mod\x20when\x20needed.\x20go\x20mod\x20edit\x20can\x20perform\x20low-level\x20edits.\x0aThe\x0agolang.org/x/mod/modfile\x0apackage\x20can\x20be\x20used\x20by\x20Go\x20programs\x20to\x20make\x20the\x20same\x20changes\x20programmatically.

\x0aLexical\x20elements\x0a

When\x20a\x20go.mod\x20file\x20is\x20parsed,\x20its\x20content\x20is\x20broken\x20into\x20a\x20sequence\x20of\x20tokens.\x0aThere\x20are\x20several\x20kinds\x20of\x20tokens:\x20whitespace,\x20comments,\x20punctuation,\x0akeywords,\x20identifiers,\x20and\x20strings.

\x0a

White\x20space\x20consists\x20of\x20spaces\x20(U+0020),\x20tabs\x20(U+0009),\x20carriage\x20returns\x0a(U+000D),\x20and\x20newlines\x20(U+000A).\x20White\x20space\x20characters\x20other\x20than\x20newlines\x20have\x0ano\x20effect\x20except\x20to\x20separate\x20tokens\x20that\x20would\x20otherwise\x20be\x20combined.\x20Newlines\x0aare\x20significant\x20tokens.

\x0a

Comments\x20start\x20with\x20//\x20and\x20run\x20to\x20the\x20end\x20of\x20a\x20line.\x20/*\x20*/\x20comments\x20are\x0anot\x20allowed.

\x0a

Punctuation\x20tokens\x20include\x20(,\x20),\x20and\x20=>.

\x0a

Keywords\x20distinguish\x20different\x20kinds\x20of\x20directives\x20in\x20a\x20go.mod\x20file.\x20Allowed\x0akeywords\x20are\x20module,\x20go,\x20require,\x20replace,\x20and\x20exclude.

\x0a

Identifiers\x20are\x20sequences\x20of\x20non-whitespace\x20characters,\x20such\x20as\x20module\x20paths\x0aor\x20semantic\x20versions.

\x0a

Strings\x20are\x20quoted\x20sequences\x20of\x20characters.\x20There\x20are\x20two\x20kinds\x20of\x20strings:\x0ainterpreted\x20strings\x20beginning\x20and\x20ending\x20with\x20quotation\x20marks\x20(",\x20U+0022)\x20and\x0araw\x20strings\x20beginning\x20and\x20ending\x20with\x20grave\x20accents\x20(<,\x0aU+0060).\x20Interpreted\x20strings\x20may\x20contain\x20escape\x20sequences\x20consisting\x20of\x20a\x0abackslash\x20(\\,\x20U+005C)\x20followed\x20by\x20another\x20character.\x20An\x20escaped\x20quotation\x0amark\x20(\\")\x20does\x20not\x20terminate\x20an\x20interpreted\x20string.\x20The\x20unquoted\x20value\x0aof\x20an\x20interpreted\x20string\x20is\x20the\x20sequence\x20of\x20characters\x20between\x20quotation\x0amarks\x20with\x20each\x20escape\x20sequence\x20replaced\x20by\x20the\x20character\x20following\x20the\x0abackslash\x20(for\x20example,\x20\\"\x20is\x20replaced\x20by\x20",\x20\\n\x20is\x20replaced\x20by\x20n).\x0aIn\x20contrast,\x20the\x20unquoted\x20value\x20of\x20a\x20raw\x20string\x20is\x20simply\x20the\x20sequence\x20of\x0acharacters\x20between\x20grave\x20accents;\x20backslashes\x20have\x20no\x20special\x20meaning\x20within\x0araw\x20strings.

\x0a

Identifiers\x20and\x20strings\x20are\x20interchangeable\x20in\x20the\x20go.mod\x20grammar.

\x0aModule\x20paths\x20and\x20versions\x0a

Most\x20identifiers\x20and\x20strings\x20in\x20a\x20go.mod\x20file\x20are\x20either\x20module\x20paths\x20or\x0aversions.

\x0a

A\x20module\x20path\x20must\x20satisfy\x20the\x20following\x20requirements:

\x0a
    \x0a
  • The\x20path\x20must\x20consist\x20of\x20one\x20or\x20more\x20path\x20elements\x20separated\x20by\x20slashes\x0a(/,\x20U+002F).\x20It\x20must\x20not\x20begin\x20or\x20end\x20with\x20a\x20slash.
  • \x0a
  • Each\x20path\x20element\x20is\x20a\x20non-empty\x20string\x20made\x20of\x20up\x20ASCII\x20letters,\x20ASCII\x0adigits,\x20and\x20limited\x20ASCII\x20punctuation\x20(+,\x20-,\x20.,\x20_,\x20and\x20~).
  • \x0a
  • A\x20path\x20element\x20may\x20not\x20begin\x20or\x20end\x20with\x20a\x20dot\x20(.,\x20U+002E).
  • \x0a
  • The\x20element\x20prefix\x20up\x20to\x20the\x20first\x20dot\x20must\x20not\x20be\x20a\x20reserved\x20file\x20name\x20on\x0aWindows,\x20regardless\x20of\x20case\x20(CON,\x20com1,\x20NuL,\x20and\x20so\x20on).
  • \x0a
\x0a

If\x20the\x20module\x20path\x20appears\x20in\x20a\x20require\x20directive\x20and\x20is\x20not\x20replaced,\x20or\x0aif\x20the\x20module\x20paths\x20appears\x20on\x20the\x20right\x20side\x20of\x20a\x20replace\x20directive,\x0athe\x20go\x20command\x20may\x20need\x20to\x20download\x20modules\x20with\x20that\x20path,\x20and\x20some\x0aadditional\x20requirements\x20must\x20be\x20satisfied.

\x0a
    \x0a
  • The\x20leading\x20path\x20element\x20(up\x20to\x20the\x20first\x20slash,\x20if\x20any),\x20by\x20convention\x20a\x0adomain\x20name,\x20must\x20contain\x20only\x20lower-case\x20ASCII\x20letters,\x20ASCII\x20digits,\x20dots\x0a(.,\x20U+002E),\x20and\x20dashes\x20(-,\x20U+002D);\x20it\x20must\x20contain\x20at\x20least\x20one\x20dot\x20and\x0acannot\x20start\x20with\x20a\x20dash.
  • \x0a
  • For\x20a\x20final\x20path\x20element\x20of\x20the\x20form\x20/vN\x20where\x20N\x20looks\x20numeric\x20(ASCII\x0adigits\x20and\x20dots),\x20N\x20must\x20not\x20begin\x20with\x20a\x20leading\x20zero,\x20must\x20not\x20be\x20/v1,\x0aand\x20must\x20not\x20contain\x20any\x20dots.\x0a
      \x0a
    • For\x20paths\x20beginning\x20with\x20gopkg.in/,\x20this\x20requirement\x20is\x20replaced\x20by\x20a\x0arequirement\x20that\x20the\x20path\x20follow\x20the\x20gopkg.in\x20service's\x0aconventions.
    • \x0a
    \x0a
  • \x0a
\x0a

Versions\x20in\x20go.mod\x20files\x20may\x20be\x20canonical\x20or\x0anon-canonical.

\x0a

A\x20canonical\x20version\x20starts\x20with\x20the\x20letter\x20v,\x20followed\x20by\x20a\x20semantic\x20version\x0afollowing\x20the\x20Semantic\x20Versioning\x202.0.0\x0aspecification.\x20See\x20Versions\x20for\x20more\x20information.

\x0a

Most\x20other\x20identifiers\x20and\x20strings\x20may\x20be\x20used\x20as\x20non-canonical\x20versions,\x20though\x0athere\x20are\x20some\x20restrictions\x20to\x20avoid\x20problems\x20with\x20file\x20systems,\x20repositories,\x0aand\x20module\x20proxies.\x20Non-canonical\x20versions\x20are\x20only\x0aallowed\x20in\x20the\x20main\x20module's\x20go.mod\x20file.\x20The\x20go\x20command\x20will\x20attempt\x20to\x0areplace\x20each\x20non-canonical\x20version\x20with\x20an\x20equivalent\x20canonical\x20version\x20when\x20it\x0aautomatically\x20updates\x20the\x20go.mod\x20file.

\x0a

In\x20places\x20where\x20a\x20module\x20path\x20is\x20associated\x20with\x20a\x20verison\x20(as\x20in\x20require,\x0areplace,\x20and\x20exclude\x20directives),\x20the\x20final\x20path\x20element\x20must\x20be\x20consistent\x0awith\x20the\x20version.\x20See\x20Major\x20version\x20suffixes.

\x0aGrammar\x0a

go.mod\x20syntax\x20is\x20specified\x20below\x20using\x20Extended\x20Backus-Naur\x20Form\x20(EBNF).\x0aSee\x20the\x20Notation\x20section\x20in\x20the\x20Go\x20Language\x20Specificiation\x0afor\x20details\x20on\x20EBNF\x20syntax.

\x0a
GoMod\x20=\x20{\x20Directive\x20}\x20.\x0aDirective\x20=\x20ModuleDirective\x20|\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20GoDirective\x20|\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20RequireDirective\x20|\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ExcludeDirective\x20|\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ReplaceDirective\x20.\x0a
\x0a

Newlines,\x20identifiers,\x20and\x20strings\x20are\x20denoted\x20with\x20newline,\x20ident,\x20and\x0astring,\x20respectively.

\x0a

Module\x20paths\x20and\x20versions\x20are\x20denoted\x20with\x20ModulePath\x20and\x20Version.

\x0a
ModulePath\x20=\x20ident\x20|\x20string\x20.\x20/*\x20see\x20restrictions\x20above\x20*/\x0aVersion\x20=\x20ident\x20|\x20string\x20.\x20\x20\x20\x20/*\x20see\x20restrictions\x20above\x20*/\x0a
\x0amodule\x20directive\x0a

A\x20module\x20directive\x20defines\x20the\x20main\x20module's\x20path.\x20A\x0ago.mod\x20file\x20must\x20contain\x20exactly\x20one\x20module\x20directive.

\x0a
ModuleDirective\x20=\x20"module"\x20(\x20ModulePath\x20|\x20"("\x20newline\x20ModulePath\x20newline\x20")"\x20newline\x20.\x0a
\x0a

Example:

\x0a
module\x20golang.org/x/net\x0a
\x0ago\x20directive\x0a

A\x20go\x20directive\x20sets\x20the\x20expected\x20language\x20version\x20for\x20the\x20module.\x20The\x0aversion\x20must\x20be\x20a\x20valid\x20Go\x20release\x20version:\x20a\x20positive\x20integer\x20followed\x20by\x20a\x20dot\x0aand\x20a\x20non-negative\x20integer\x20(for\x20example,\x201.9,\x201.14).

\x0a

The\x20language\x20version\x20determines\x20which\x20language\x20features\x20are\x20available\x20when\x0acompiling\x20packages\x20in\x20the\x20module.\x20Language\x20features\x20present\x20in\x20that\x20version\x0awill\x20be\x20available\x20for\x20use.\x20Language\x20features\x20removed\x20in\x20earlier\x20versions,\x0aor\x20added\x20in\x20later\x20versions,\x20will\x20not\x20be\x20available.\x20The\x20language\x20version\x20does\x20not\x0aaffect\x20build\x20tags,\x20which\x20are\x20determined\x20by\x20the\x20Go\x20release\x20being\x20used.

\x0a

The\x20language\x20version\x20is\x20also\x20used\x20to\x20enable\x20features\x20in\x20the\x20go\x20command.\x20For\x0aexample,\x20automatic\x20vendoring\x20may\x20be\x20enabled\x20with\x20a\x20go\x20version\x20of\x0a1.14\x20or\x20higher.

\x0a

A\x20go.mod\x20file\x20may\x20contain\x20at\x20most\x20one\x20go\x20directive.\x20Most\x20commands\x20will\x20add\x20a\x0ago\x20directive\x20with\x20the\x20current\x20Go\x20version\x20if\x20one\x20is\x20not\x20present.

\x0a
GoDirective\x20=\x20"go"\x20GoVersion\x20newline\x20.\x0aGoVersion\x20=\x20string\x20|\x20ident\x20.\x20\x20/*\x20valid\x20release\x20version;\x20see\x20above\x20*/\x0a
\x0a

Example:

\x0a
go\x201.14\x0a
\x0arequire\x20directive\x0a

A\x20require\x20directive\x20declares\x20a\x20minimum\x20required\x20version\x20of\x20a\x20given\x20module\x0adependency.\x20For\x20each\x20required\x20module\x20version,\x20the\x20go\x20command\x20loads\x20the\x0ago.mod\x20file\x20for\x20that\x20version\x20and\x20incorporates\x20the\x20requirements\x20from\x20that\x0afile.\x20Once\x20all\x20requirements\x20have\x20been\x20loaded,\x20the\x20go\x20command\x20resolves\x20them\x0ausing\x20minimal\x20version\x20selection\x20(MVS)\x20to\x20produce\x0athe\x20build\x20list.

\x0a

The\x20go\x20command\x20automatically\x20adds\x20//\x20indirect\x20comments\x20for\x20some\x0arequirements.\x20An\x20//\x20indirect\x20comment\x20indicates\x20that\x20no\x20package\x20from\x20the\x0arequired\x20module\x20is\x20directly\x20imported\x20by\x20any\x20package\x20in\x20the\x20main\x20module.\x0aThe\x20go\x20command\x20adds\x20an\x20indirect\x20requirement\x20when\x20the\x20selected\x20version\x20of\x20a\x0amodule\x20is\x20higher\x20than\x20what\x20is\x20already\x20implied\x20(transitively)\x20by\x20the\x20main\x0amodule's\x20other\x20dependencies.\x20That\x20may\x20occur\x20because\x20of\x20an\x20explicit\x20upgrade\x0a(go\x20get\x20-u),\x20removal\x20of\x20some\x20other\x20dependency\x20that\x20previously\x20imposed\x20the\x0arequirement\x20(go\x20mod\x20tidy),\x20or\x20a\x20dependency\x20that\x20imports\x20a\x20package\x20without\x0aa\x20corresponding\x20requirement\x20in\x20its\x20own\x20go.mod\x20file\x20(such\x20as\x20a\x20dependency\x0athat\x20lacks\x20a\x20go.mod\x20file\x20altogether).

\x0a
RequireDirective\x20=\x20"require"\x20(\x20RequireSpec\x20|\x20"("\x20newline\x20{\x20RequireSpec\x20}\x20")"\x20newline\x20)\x20.\x0aRequireSpec\x20=\x20ModulePath\x20Version\x20newline\x20.\x0a
\x0a

Example:

\x0a
require\x20golang.org/x/net\x20v1.2.3\x0a\x0arequire\x20(\x0a\x20\x20\x20\x20golang.org/x/crypto\x20v1.4.5\x20//\x20indirect\x0a\x20\x20\x20\x20golang.org/x/text\x20v1.6.7\x0a)\x0a
\x0aexclude\x20directive\x0a

An\x20exclude\x20directive\x20prevents\x20a\x20module\x20version\x20from\x20being\x20loaded\x20by\x20the\x20go\x0acommand.\x20If\x20an\x20excluded\x20version\x20is\x20referenced\x20by\x20a\x20require\x20directive\x20in\x20a\x0ago.mod\x20file,\x20the\x20go\x20command\x20will\x20list\x20available\x20versions\x20for\x20the\x20module\x20(as\x0ashown\x20with\x20go\x20list\x20-m\x20-versions)\x20and\x20will\x20load\x20the\x20next\x20higher\x20non-excluded\x0aversion\x20instead.\x20Both\x20release\x20and\x20pre-release\x20versions\x20are\x20considered\x20for\x20this\x0apurpose,\x20but\x20pseudo-versions\x20are\x20not.\x20If\x20there\x20are\x20no\x20higher\x20versions,\x0athe\x20go\x20command\x20will\x20report\x20an\x20error.\x20Note\x20that\x20this\x20may\x0achange\x20in\x20Go\x201.15.

\x0a\x0a

exclude\x20directives\x20only\x20apply\x20in\x20the\x20main\x20module's\x20go.mod\x20file\x20and\x20are\x0aignored\x20in\x20other\x20modules.\x20See\x20Minimal\x20version\x0aselection\x20for\x20details.

\x0a
ExcludeDirective\x20=\x20"exclude"\x20(\x20ExcludeSpec\x20|\x20"("\x20newline\x20{\x20ExcludeSpec\x20}\x20")"\x20)\x20.\x0aExcludeSpec\x20=\x20ModulePath\x20Version\x20newline\x20.\x0a
\x0a

Example:

\x0a
exclude\x20golang.org/x/net\x20v1.2.3\x0a\x0aexclude\x20(\x0a\x20\x20\x20\x20golang.org/x/crypto\x20v1.4.5\x0a\x20\x20\x20\x20golang.org/x/text\x20v1.6.7\x0a)\x0a
\x0areplace\x20directive\x0a

A\x20replace\x20directive\x20replaces\x20the\x20contents\x20of\x20a\x20specific\x20version\x20of\x20a\x20module,\x0aor\x20all\x20versions\x20of\x20a\x20module,\x20with\x20contents\x20found\x20elsewhere.\x20The\x20replacement\x0amay\x20be\x20specified\x20with\x20either\x20another\x20module\x20path\x20and\x20version,\x20or\x20a\x0aplatform-specific\x20file\x20path.

\x0a

If\x20a\x20version\x20is\x20present\x20on\x20the\x20left\x20side\x20of\x20the\x20arrow\x20(=>),\x20only\x20that\x20specific\x0aversion\x20of\x20the\x20module\x20is\x20replaced;\x20other\x20versions\x20will\x20be\x20accessed\x20normally.\x0aIf\x20the\x20left\x20version\x20is\x20omitted,\x20all\x20versions\x20of\x20the\x20module\x20are\x20replaced.

\x0a

If\x20the\x20path\x20on\x20the\x20right\x20side\x20of\x20the\x20arrow\x20is\x20an\x20absolute\x20or\x20relative\x20path\x0a(beginning\x20with\x20./\x20or\x20../),\x20it\x20is\x20interpreted\x20as\x20the\x20local\x20file\x20path\x20to\x20the\x0areplacement\x20module\x20root\x20directory,\x20which\x20must\x20contain\x20a\x20go.mod\x20file.\x20The\x0areplacement\x20version\x20must\x20be\x20omitted\x20in\x20this\x20case.

\x0a

If\x20the\x20path\x20on\x20the\x20right\x20side\x20is\x20not\x20a\x20local\x20path,\x20it\x20must\x20be\x20a\x20valid\x20module\x0apath.\x20In\x20this\x20case,\x20a\x20version\x20is\x20required.\x20The\x20same\x20module\x20version\x20must\x20not\x0aalso\x20appear\x20in\x20the\x20build\x20list.

\x0a

Regardless\x20of\x20whether\x20a\x20replacement\x20is\x20specified\x20with\x20a\x20local\x20path\x20or\x20module\x0apath,\x20if\x20the\x20replacement\x20module\x20has\x20a\x20go.mod\x20file,\x20its\x20module\x20directive\x0amust\x20match\x20the\x20module\x20path\x20it\x20replaces.

\x0a

replace\x20directives\x20only\x20apply\x20in\x20the\x20main\x20module's\x20go.mod\x20file\x0aand\x20are\x20ignored\x20in\x20other\x20modules.\x20See\x20Minimal\x20version\x0aselection\x20for\x20details.

\x0a
ReplaceDirective\x20=\x20"replace"\x20(\x20ReplaceSpec\x20|\x20"("\x20newline\x20{\x20ReplaceSpec\x20}\x20")"\x20newline\x20")"\x20)\x20.\x0aReplaceSpec\x20=\x20ModulePath\x20[\x20Version\x20]\x20"=>"\x20FilePath\x20newline\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20|\x20ModulePath\x20[\x20Version\x20]\x20"=>"\x20ModulePath\x20Version\x20newline\x20.\x0aFilePath\x20=\x20/*\x20platform-specific\x20relative\x20or\x20absolute\x20file\x20path\x20*/\x0a
\x0a

Example:

\x0a
replace\x20golang.org/x/net\x20v1.2.3\x20=>\x20example.com/fork/net\x20v1.4.5\x0a\x0areplace\x20(\x0a\x20\x20\x20\x20golang.org/x/net\x20v1.2.3\x20=>\x20example.com/fork/net\x20v1.4.5\x0a\x20\x20\x20\x20golang.org/x/net\x20=>\x20example.com/fork/net\x20v1.4.5\x0a\x20\x20\x20\x20golang.org/x/net\x20v1.2.3\x20=>\x20./fork/net\x0a\x20\x20\x20\x20golang.org/x/net\x20=>\x20./fork/net\x0a)\x0a
\x0aAutomatic\x20updates\x0a

The\x20go\x20command\x20automatically\x20updates\x20go.mod\x20when\x20it\x20uses\x20the\x20module\x20graph\x20if\x0asome\x20information\x20is\x20missing\x20or\x20go.mod\x20doesn't\x20accurately\x20reflect\x20reality.\x20\x20For\x0aexample,\x20consider\x20this\x20go.mod\x20file:

\x0a
module\x20example.com/M\x0a\x0arequire\x20(\x0a\x20\x20\x20\x20example.com/A\x20v1\x0a\x20\x20\x20\x20example.com/B\x20v1.0.0\x0a\x20\x20\x20\x20example.com/C\x20v1.0.0\x0a\x20\x20\x20\x20example.com/D\x20v1.2.3\x0a\x20\x20\x20\x20example.com/E\x20dev\x0a)\x0a\x0aexclude\x20example.com/D\x20v1.2.3\x0a
\x0a

The\x20update\x20rewrites\x20non-canonical\x20version\x20identifiers\x20to\x0acanonical\x20semver\x20form,\x20so\x20example.com/A's\x20v1\x0abecomes\x20v1.0.0,\x20and\x20example.com/E's\x20dev\x20becomes\x20the\x20pseudo-version\x20for\x20the\x0alatest\x20commit\x20on\x20the\x20dev\x20branch,\x20perhaps\x20v0.0.0-20180523231146-b3f5c0f6e5f1.

\x0a

The\x20update\x20modifies\x20requirements\x20to\x20respect\x20exclusions,\x20so\x20the\x20requirement\x20on\x0athe\x20excluded\x20example.com/D\x20v1.2.3\x20is\x20updated\x20to\x20use\x20the\x20next\x20available\x20version\x0aof\x20example.com/D,\x20perhaps\x20v1.2.4\x20or\x20v1.3.0.

\x0a

The\x20update\x20removes\x20redundant\x20or\x20misleading\x20requirements.\x20For\x20example,\x20if\x0aexample.com/A\x20v1.0.0\x20itself\x20requires\x20example.com/B\x20v1.2.0\x20and\x20example.com/C\x20v1.0.0,\x20then\x20go.mod's\x20requirement\x20of\x20example.com/B\x20v1.0.0\x20is\x20misleading\x0a(superseded\x20by\x20example.com/A's\x20need\x20for\x20v1.2.0),\x20and\x20its\x20requirement\x20of\x0aexample.com/C\x20v1.0.0\x20is\x20redundant\x20(implied\x20by\x20example.com/A's\x20need\x20for\x20the\x0asame\x20version),\x20so\x20both\x20will\x20be\x20removed.\x20If\x20the\x20main\x20module\x20contains\x20packages\x0athat\x20directly\x20import\x20packages\x20from\x20example.com/B\x20or\x20example.com/C,\x20then\x20the\x0arequirements\x20will\x20be\x20kept\x20but\x20updated\x20to\x20the\x20actual\x20versions\x20being\x20used.

\x0a

Finally,\x20the\x20update\x20reformats\x20the\x20go.mod\x20in\x20a\x20canonical\x20formatting,\x20so\x0athat\x20future\x20mechanical\x20changes\x20will\x20result\x20in\x20minimal\x20diffs.\x20The\x20go\x20command\x0awill\x20not\x20update\x20go.mod\x20if\x20only\x20formatting\x20changes\x20are\x20needed.

\x0a

Because\x20the\x20module\x20graph\x20defines\x20the\x20meaning\x20of\x20import\x20statements,\x20any\x20commands\x0athat\x20load\x20packages\x20also\x20use\x20and\x20therefore\x20update\x20go.mod,\x20including\x20go\x20build,\x0ago\x20get,\x20go\x20install,\x20go\x20list,\x20go\x20test,\x20go\x20mod\x20graph,\x20go\x20mod\x20tidy,\x20and\x0ago\x20mod\x20why.

\x0a

The\x20-mod=readonly\x20flag\x20prevents\x20commands\x20from\x20automatically\x20updating\x0ago.mod.\x20However,\x20if\x20a\x20command\x20needs\x20to\x20perform\x20an\x20action\x20that\x20would\x0aupdate\x20to\x20go.mod,\x20it\x20will\x20report\x20an\x20error.\x20For\x20example,\x20if\x0ago\x20build\x20is\x20asked\x20to\x20build\x20a\x20package\x20not\x20provided\x20by\x20any\x20module\x20in\x20the\x20build\x0alist,\x20go\x20build\x20will\x20report\x20an\x20error\x20instead\x20of\x20looking\x20up\x20the\x20module\x20and\x0aupdating\x20requirements\x20in\x20go.mod.

\x0aMinimal\x20version\x20selection\x20(MVS)\x0a

Go\x20uses\x20an\x20algorithm\x20called\x20Minimal\x20version\x20selection\x20(MVS)\x20to\x20select\x0aa\x20set\x20of\x20module\x20versions\x20to\x20use\x20when\x20building\x20packages.\x20MVS\x20is\x20described\x20in\x0adetail\x20in\x20Minimal\x20Version\x20Selection\x20by\x0aRuss\x20Cox.

\x0a

Conceptually,\x20MVS\x20operates\x20on\x20a\x20directed\x20graph\x20of\x20modules,\x20specified\x20with\x0ago.mod\x20files.\x20Each\x20vertex\x20in\x20the\x20graph\x20represents\x20a\x0amodule\x20version.\x20Each\x20edge\x20represents\x20a\x20minimum\x20required\x20version\x20of\x20a\x20dependency,\x0aspecified\x20using\x20a\x20require\x0adirective.\x20replace\x20and\x20exclude\x0adirectives\x20in\x20the\x20main\x20module's\x20go.mod\x20file\x20modify\x20the\x20graph.

\x0a

MVS\x20produces\x20the\x20build\x20list\x20as\x20output,\x20the\x20list\x20of\x20module\x0aversions\x20used\x20for\x20a\x20build.

\x0a

MVS\x20starts\x20at\x20the\x20main\x20module\x20(a\x20special\x20vertex\x20in\x20the\x20graph\x20that\x20has\x20no\x0aversion)\x20and\x20traverses\x20the\x20graph,\x20tracking\x20the\x20highest\x20required\x20version\x20of\x20each\x0amodule.\x20At\x20the\x20end\x20of\x20the\x20traversal,\x20the\x20highest\x20required\x20versions\x20comprise\x20the\x0abuild\x20list:\x20they\x20are\x20the\x20minimum\x20versions\x20that\x20satisfy\x20all\x20requirements.

\x0a

The\x20build\x20list\x20may\x20be\x20inspected\x20with\x20the\x20command\x20go\x20list\x20-m\x20all.\x20Unlike\x20other\x20dependency\x20management\x20systems,\x20the\x20build\x20list\x20is\x0anot\x20saved\x20in\x20a\x20"lock"\x20file.\x20MVS\x20is\x20deterministic,\x20and\x20the\x20build\x20list\x20doesn't\x0achange\x20when\x20new\x20versions\x20of\x20dependencies\x20are\x20released,\x20so\x20MVS\x20is\x20used\x20to\x20compute\x0ait\x20at\x20the\x20beginning\x20of\x20every\x20module-aware\x20command.

\x0a

Consider\x20the\x20example\x20in\x20the\x20diagram\x20below.\x20The\x20main\x20module\x20requires\x20module\x20A\x0aat\x20version\x201.2\x20or\x20higher\x20and\x20module\x20B\x20at\x20version\x201.2\x20or\x20higher.\x20A\x201.2\x20and\x20B\x201.2\x0arequire\x20C\x201.3\x20and\x20C\x201.4,\x20respectively.\x20C\x201.3\x20and\x20C\x201.4\x20both\x20require\x20D\x201.2.

\x0a

\x0a

MVS\x20visits\x20and\x20loads\x20the\x20go.mod\x20file\x20for\x20each\x20of\x20the\x20module\x20versions\x0ahighlighted\x20in\x20blue.\x20At\x20the\x20end\x20of\x20the\x20graph\x20traversal,\x20MVS\x20returns\x20a\x20build\x20list\x0acontaining\x20the\x20bolded\x20versions:\x20A\x201.2,\x20B\x201.2,\x20C\x201.4,\x20and\x20D\x201.2.\x20Note\x20that\x20higher\x0aversions\x20of\x20B\x20and\x20D\x20are\x20available\x20but\x20MVS\x20does\x20not\x20select\x20them,\x20since\x20nothing\x0arequires\x20them.

\x0aReplacement\x0a

The\x20content\x20of\x20a\x20module\x20(including\x20its\x20go.mod\x20file)\x20may\x20be\x20replaced\x20using\x20a\x0areplace\x20directive\x20in\x20the\x20the\x20main\x20module's\x20go.mod\x20file.\x0aA\x20replace\x20directive\x20may\x20apply\x20to\x20a\x20specific\x20version\x20of\x20a\x20module\x20or\x20to\x20all\x0aversions\x20of\x20a\x20module.

\x0a

Replacements\x20change\x20the\x20module\x20graph,\x20since\x20a\x20replacement\x20module\x20may\x20have\x0adifferent\x20dependencies\x20than\x20replaced\x20versions.

\x0a

Consider\x20the\x20example\x20below,\x20where\x20C\x201.4\x20has\x20been\x20replaced\x20with\x20R.\x20R\x20depends\x20on\x20D\x0a1.3\x20instead\x20of\x20D\x201.2,\x20so\x20MVS\x20returns\x20a\x20build\x20list\x20containing\x20A\x201.2,\x20B\x201.2,\x20C\x201.4\x0a(replaced\x20with\x20R),\x20and\x20D\x201.3.

\x0a

\x0aExclusion\x0a

A\x20module\x20may\x20also\x20be\x20excluded\x20at\x20specific\x20versions\x20using\x20an\x20exclude\x0adirective\x20in\x20the\x20main\x20module's\x20go.mod\x20file.

\x0a

Exclusions\x20also\x20change\x20the\x20module\x20graph.\x20When\x20a\x20version\x20is\x20excluded,\x20it\x20is\x0aremoved\x20from\x20the\x20module\x20graph,\x20and\x20requirements\x20on\x20it\x20are\x20redirected\x20to\x20the\x0anext\x20higher\x20version.

\x0a

Consider\x20the\x20example\x20below.\x20C\x201.3\x20has\x20been\x20excluded.\x20MVS\x20will\x20act\x20as\x20if\x20A\x201.2\x0arequired\x20C\x201.4\x20(the\x20next\x20higher\x20version)\x20instead\x20of\x20C\x201.3.

\x0a

\x0aUpgrades\x0a

The\x20go\x20get\x20command\x20may\x20be\x20used\x20to\x20upgrade\x20a\x20set\x20of\x20modules.\x20To\x0aperform\x20an\x20upgrade,\x20the\x20go\x20command\x20changes\x20the\x20module\x20graph\x20before\x20running\x20MVS\x0aby\x20adding\x20edges\x20from\x20visited\x20versions\x20to\x20upgraded\x20versions.

\x0a

Consider\x20the\x20example\x20below.\x20Module\x20B\x20may\x20be\x20upgraded\x20from\x201.2\x20to\x201.3,\x20C\x20may\x20be\x0aupgraded\x20from\x201.3\x20to\x201.4,\x20and\x20D\x20may\x20be\x20upgraded\x20from\x201.2\x20to\x201.3.

\x0a

\x0a

Upgrades\x20(and\x20downgrades)\x20may\x20add\x20or\x20remove\x20indirect\x20dependencies.\x20In\x20this\x20case,\x0aE\x201.1\x20and\x20F\x201.1\x20appear\x20in\x20the\x20build\x20list\x20after\x20the\x20upgrade,\x20since\x20E\x201.1\x20is\x0arequired\x20by\x20B\x201.3.

\x0a

To\x20preserve\x20upgrades,\x20the\x20go\x20command\x20updates\x20the\x20requirements\x20in\x20go.mod.\x20\x20It\x0awill\x20change\x20the\x20requirement\x20on\x20B\x20to\x20version\x201.3.\x20It\x20will\x20also\x20add\x20requirements\x0aon\x20C\x201.4\x20and\x20D\x201.3\x20with\x20//\x20indirect\x20comments,\x20since\x20those\x20versions\x20would\x20not\x0abe\x20selected\x20otherwise.

\x0aDowngrade\x0a

The\x20go\x20get\x20command\x20may\x20also\x20be\x20used\x20to\x20downgrade\x20a\x20set\x20of\x0amodules.\x20To\x20perform\x20a\x20downgrade,\x20the\x20go\x20command\x20changes\x20the\x20module\x20graph\x20by\x0aremoving\x20versions\x20above\x20the\x20downgraded\x20versions.\x20It\x20also\x20removes\x20versions\x20of\x0aother\x20modules\x20that\x20depend\x20on\x20removed\x20versions,\x20since\x20they\x20may\x20not\x20be\x20compatible\x0awith\x20the\x20downgraded\x20versions\x20of\x20their\x20dependencies.\x20If\x20the\x20main\x20module\x20requires\x0aa\x20module\x20version\x20removed\x20by\x20downgrading,\x20the\x20requirement\x20is\x20changed\x20to\x20a\x0aprevious\x20version\x20that\x20has\x20not\x20been\x20removed.\x20If\x20no\x20previous\x20version\x20is\x20available,\x0athe\x20requirement\x20is\x20dropped.

\x0a

Consider\x20the\x20example\x20below.\x20Suppose\x20that\x20a\x20problem\x20was\x20found\x20with\x20C\x201.4,\x20so\x20we\x0adowngrade\x20to\x20C\x201.3.\x20C\x201.4\x20is\x20removed\x20from\x20the\x20module\x20graph.\x20B\x201.2\x20is\x20also\x0aremoved,\x20since\x20it\x20requires\x20C\x201.4\x20or\x20higher.\x20The\x20main\x20module's\x20requirement\x20on\x20B\x0ais\x20changed\x20to\x201.1.

\x0a

\x0a

go\x20get\x20can\x20also\x20remove\x20dependencies\x20entirely,\x20using\x20an\x20@none\x0asuffix\x20after\x20an\x20argument.\x20This\x20works\x20similarly\x20to\x20a\x20downgrade.\x20All\x20versions\x0aof\x20the\x20named\x20module\x20are\x20removed\x20from\x20the\x20module\x20graph.

\x0aCompatibility\x20with\x20non-module\x20repositories\x0a

To\x20ensure\x20a\x20smooth\x20transition\x20from\x20GOPATH\x20to\x20modules,\x20the\x20go\x20command\x20can\x0adownload\x20and\x20build\x20packages\x20in\x20module-aware\x20mode\x20from\x20repositories\x20that\x20have\x20not\x0amigrated\x20to\x20modules\x20by\x20adding\x20a\x20go.mod\x20file.

\x0a

When\x20the\x20go\x20command\x20downloads\x20a\x20module\x20at\x20a\x20given\x20version\x20directly\x0afrom\x20a\x20repository,\x20it\x20looks\x20up\x20a\x20repository\x20URL\x20for\x20the\x20module\x20path,\x20maps\x20the\x0aversion\x20to\x20a\x20revision\x20within\x20the\x20repository,\x20then\x20extracts\x20an\x20archive\x20of\x20the\x0arepository\x20at\x20that\x20revision.\x20If\x20the\x20module's\x20path\x20is\x20equal\x0ato\x20the\x20repository\x20root\x20path,\x20and\x20the\x20repository\x0aroot\x20directory\x20does\x20not\x20contain\x20a\x20go.mod\x20file,\x20the\x20go\x20command\x20synthesizes\x20a\x0ago.mod\x20file\x20in\x20the\x20module\x20cache\x20that\x20contains\x20a\x20module\x0adirective\x20and\x20nothing\x20else.\x20Since\x20synthetic\x20go.mod\x20files\x20do\x0anot\x20contain\x20require\x20directives\x20for\x20their\x20dependencies,\x0aother\x20modules\x20that\x20depend\x20on\x20them\x20may\x20need\x20additional\x20require\x20directives\x20(with\x0a//\x20indirect\x20comments)\x20to\x20ensure\x20each\x20dependency\x20is\x20fetched\x20at\x20the\x20same\x20version\x0aon\x20every\x20build.

\x0a

When\x20the\x20go\x20command\x20downloads\x20a\x20module\x20from\x20a\x0aproxy,\x20it\x20downloads\x20the\x20go.mod\x20file\x20separately\x0afrom\x20the\x20rest\x20of\x20the\x20module\x20content.\x20The\x20proxy\x20is\x20expected\x20to\x20serve\x20a\x20synthetic\x0ago.mod\x20file\x20if\x20the\x20original\x20module\x20didn't\x20have\x20one.

\x0a+incompatible\x20versions\x0a

A\x20module\x20released\x20at\x20major\x20version\x202\x20or\x20higher\x20must\x20have\x20a\x20matching\x20major\x0aversion\x20suffix\x20on\x20its\x20module\x20path.\x20For\x20example,\x20if\x20a\x0amodule\x20is\x20released\x20at\x20v2.0.0,\x20its\x20path\x20must\x20have\x20a\x20/v2\x20suffix.\x20This\x20allows\x0athe\x20go\x20command\x20to\x20treat\x20multiple\x20major\x20versions\x20of\x20a\x20project\x20as\x20distinct\x0amodules,\x20even\x20if\x20they're\x20developed\x20in\x20the\x20same\x20repository.

\x0a

The\x20major\x20version\x20suffix\x20requirement\x20was\x20introduced\x20when\x20module\x20support\x20was\x0aadded\x20to\x20the\x20go\x20command,\x20and\x20many\x20repositories\x20had\x20already\x20tagged\x20releases\x0awith\x20major\x20version\x202\x20or\x20higher\x20before\x20that.\x20To\x20maintain\x20compatibility\x20with\x0athese\x20repositories,\x20the\x20go\x20command\x20adds\x20an\x20+incompatible\x20suffix\x20to\x20versions\x0awith\x20major\x20version\x202\x20or\x20higher\x20without\x20a\x20go.mod\x20file.\x20+incompatible\x0aindicates\x20that\x20a\x20version\x20is\x20part\x20of\x20the\x20same\x20module\x20as\x20versions\x20with\x20lower\x20major\x0aversion\x20numbers;\x20consequently,\x20the\x20go\x20command\x20may\x20automatically\x20upgrade\x20to\x0ahigher\x20+incompatible\x20versions\x20even\x20though\x20it\x20may\x20break\x20the\x20build.

\x0a

Consider\x20the\x20example\x20requirement\x20below:

\x0a
require\x20example.com/m\x20v4.1.2+incompatible\x0a
\x0a

The\x20version\x20v4.1.2+incompatible\x20refers\x20to\x20the\x20semantic\x20version\x0atag\x20v4.1.2\x20in\x20the\x20repository\x20that\x20provides\x20the\x0amodule\x20example.com/m.\x20The\x20module\x20must\x20be\x20in\x20the\x20repository\x20root\x20directory\x0a(that\x20is,\x20the\x20repository\x20root\x20path\x20must\x20also\x20be\x0aexample.com/m),\x20and\x20a\x20go.mod\x20file\x20must\x20not\x20be\x20present.\x20The\x20module\x20may\x20have\x0aversions\x20with\x20lower\x20major\x20version\x20numbers\x20like\x20v1.5.2,\x20and\x20the\x20go\x20command\x0amay\x20upgrade\x20automatically\x20to\x20v4.1.2+incompatible\x20from\x20those\x20versions\x20(see\x0aminimal\x20version\x20selection\x20(MVS)\x20for\x20information\x0aon\x20how\x20upgrades\x20work).

\x0a

A\x20repository\x20that\x20migrates\x20to\x20modules\x20after\x20version\x20v2.0.0\x20is\x20tagged\x20should\x0ausually\x20release\x20a\x20new\x20major\x20version.\x20In\x20the\x20example\x20above,\x20the\x20author\x20should\x0acreate\x20a\x20module\x20with\x20the\x20path\x20example.com/m/v5\x20and\x20should\x20release\x20version\x0av5.0.0.\x20The\x20author\x20should\x20also\x20update\x20imports\x20of\x20packages\x20in\x20the\x20module\x20to\x20use\x0athe\x20prefix\x20example.com/m/v5\x20instead\x20of\x20example.com/m.\x20See\x20Go\x20Modules:\x20v2\x0aand\x20Beyond\x20for\x20a\x20more\x20detailed\x20example.

\x0a

Note\x20that\x20the\x20+incompatible\x20suffix\x20should\x20not\x20appear\x20on\x20a\x20tag\x20in\x20a\x20repository;\x0aa\x20tag\x20like\x20v4.1.2+incompatible\x20will\x20be\x20ignored.\x20The\x20suffix\x20only\x20appears\x20in\x0aversions\x20used\x20by\x20the\x20go\x20command.\x20See\x20Mapping\x20versions\x20to\x0acommits\x20for\x20details\x20on\x20the\x20distinction\x20between\x20versions\x20and\x20tags.

\x0a

Note\x20also\x20that\x20the\x20+incompatible\x20suffix\x20may\x20appear\x20on\x0apseudo-versions.\x20For\x20example,\x0av2.0.1-20200722182040-012345abcdef+incompatible\x20may\x20be\x20a\x20valid\x20pseudo-version.

\x0aMinimal\x20module\x20compatibility\x0a

A\x20module\x20released\x20at\x20major\x20version\x202\x20or\x20higher\x20is\x20required\x20to\x20have\x20a\x20major\x0aversion\x20suffix\x20on\x20its\x20module\x0apath.\x20The\x20module\x20may\x20or\x20may\x20not\x20be\x20developed\x20in\x20a\x20major\x0aversion\x20subdirectory\x20within\x20its\x20repository.\x0aThis\x20has\x20implications\x20for\x20packages\x20that\x20import\x20packages\x20within\x20the\x20module\x20when\x0abuilding\x20GOPATH\x20mode.

\x0a

Normally\x20in\x20GOPATH\x20mode,\x20a\x20package\x20is\x20stored\x20in\x20a\x20directory\x20matching\x20its\x0arepository's\x20root\x20path\x20joined\x20with\x20its\x20diretory\x0awithin\x20the\x20repository.\x20For\x20example,\x20a\x20package\x20in\x20the\x20repository\x20with\x20root\x20path\x0aexample.com/repo\x20in\x20the\x20subdirectory\x20sub\x20would\x20be\x20stored\x20in\x0a$GOPATH/src/example.com/repo/sub\x20and\x20would\x20be\x20imported\x20as\x0aexample.com/repo/sub.

\x0a

For\x20a\x20module\x20with\x20a\x20major\x20version\x20suffix,\x20one\x20might\x20expect\x20to\x20find\x20the\x20package\x0aexample.com/repo/v2/sub\x20in\x20the\x20directory\x0a$GOPATH/src/example.com/repo/v2/sub.\x20This\x20would\x20require\x20the\x20module\x20to\x20be\x0adeveloped\x20in\x20the\x20v2\x20subdirectory\x20of\x20its\x20repository.\x20The\x20go\x20command\x20supports\x0athis\x20but\x20does\x20not\x20require\x20it\x20(see\x20Mapping\x20versions\x20to\x20commits).

\x0a

If\x20a\x20module\x20is\x20not\x20developed\x20in\x20a\x20major\x20version\x20subdirectory,\x20then\x20its\x0adirectory\x20in\x20GOPATH\x20will\x20not\x20contain\x20the\x20major\x20version\x20suffix,\x20and\x20its\x0apackages\x20may\x20be\x20imported\x20without\x20the\x20major\x20version\x20suffix.\x20In\x20the\x20example\x20above,\x0athe\x20package\x20would\x20be\x20found\x20in\x20the\x20directory\x20$GOPATH/src/example.com/repo/sub\x0aand\x20would\x20be\x20imported\x20as\x20example.com/repo/sub.

\x0a

This\x20creates\x20a\x20problem\x20for\x20packages\x20intended\x20to\x20be\x20built\x20in\x20both\x20module\x20mode\x0aand\x20GOPATH\x20mode:\x20module\x20mode\x20requires\x20a\x20suffix,\x20while\x20GOPATH\x20mode\x20does\x20not.

\x0a

To\x20fix\x20this,\x20minimal\x20module\x20compatibility\x20was\x20added\x20in\x20Go\x201.11\x20and\x0awas\x20backported\x20to\x20Go\x201.9.7\x20and\x201.10.3.\x20When\x20an\x20import\x20path\x20is\x20resolved\x20to\x20a\x0adirectory\x20in\x20GOPATH\x20mode:

\x0a
    \x0a
  • When\x20resolving\x20an\x20import\x20of\x20the\x20form\x20$modpath/$vn/$dir\x20where:\x0a
      \x0a
    • $modpath\x20is\x20a\x20valid\x20module\x20path,
    • \x0a
    • $vn\x20is\x20a\x20major\x20version\x20suffix,
    • \x0a
    • $dir\x20is\x20a\x20possibly\x20empty\x20subdirectory,
    • \x0a
    \x0a
  • \x0a
  • If\x20all\x20of\x20the\x20following\x20are\x20true:\x0a
      \x0a
    • The\x20package\x20$modpath/$vn/$dir\x20is\x20not\x20present\x20in\x20any\x20relevant\x20vendor\x0adirectory.
    • \x0a
    • A\x20go.mod\x20file\x20is\x20present\x20in\x20the\x20same\x20directory\x20as\x20the\x20importing\x20file\x0aor\x20in\x20any\x20parent\x20directory\x20up\x20to\x20the\x20$GOPATH/src\x20root,
    • \x0a
    • No\x20$GOPATH[i]/src/$modpath/$vn/$suffix\x20directory\x20exists\x20(for\x20any\x20root\x0a$GOPATH[i]),
    • \x0a
    • The\x20file\x20$GOPATH[d]/src/$modpath/go.mod\x20exists\x20(for\x20some\x20root\x0a$GOPATH[d])\x20and\x20declares\x20the\x20module\x20path\x20as\x20$modpath/$vn,
    • \x0a
    \x0a
  • \x0a
  • Then\x20the\x20import\x20of\x20$modpath/$vn/$dir\x20is\x20resolved\x20to\x20the\x20directory\x0a$GOPATH[d]/src/$modpath/$dir.
  • \x0a
\x0a

This\x20rules\x20allow\x20packages\x20that\x20have\x20been\x20migrated\x20to\x20modules\x20to\x20import\x20other\x0apackages\x20that\x20have\x20been\x20migrated\x20to\x20modules\x20when\x20built\x20in\x20GOPATH\x20mode\x20even\x0awhen\x20a\x20major\x20version\x20subdirectory\x20was\x20not\x20used.

\x0aModule-aware\x20commands\x0a

Most\x20go\x20commands\x20may\x20run\x20in\x20Module-aware\x20mode\x20or\x20GOPATH\x20mode.\x20In\x0amodule-aware\x20mode,\x20the\x20go\x20command\x20uses\x20go.mod\x20files\x20to\x20find\x20versioned\x0adependencies,\x20and\x20it\x20typically\x20loads\x20packages\x20out\x20of\x20the\x20module\x0acache,\x20downloading\x20modules\x20if\x20they\x20are\x20missing.\x20In\x20GOPATH\x0amode,\x20the\x20go\x20command\x20ignores\x20modules;\x20it\x20looks\x20in\x20vendor\x0adirectories\x20and\x20in\x20GOPATH\x20to\x20find\x20dependencies.

\x0a

Module-aware\x20mode\x20is\x20active\x20by\x20default\x20whenever\x20a\x20go.mod\x20file\x20is\x20found\x20in\x20the\x0acurrent\x20directory\x20or\x20in\x20any\x20parent\x20directory.\x20For\x20more\x20fine-grained\x20control,\x20the\x0aGO111MODULE\x20environment\x20variable\x20may\x20be\x20set\x20to\x20one\x20of\x20three\x20values:\x20on,\x0aoff,\x20or\x20auto.

\x0a
    \x0a
  • If\x20GO111MODULE=off,\x20the\x20go\x20command\x20ignores\x20go.mod\x20files\x20and\x20runs\x20in\x0aGOPATH\x20mode.
  • \x0a
  • If\x20GO111MODULE=on,\x20the\x20go\x20command\x20runs\x20in\x20module-aware\x20mode,\x20even\x20when\x0ano\x20go.mod\x20file\x20is\x20present.\x20Not\x20all\x20commands\x20work\x20without\x20a\x20go.mod\x20file:\x0asee\x20Module\x20commands\x20outside\x20a\x20module.
  • \x0a
  • If\x20GO111MODULE=auto\x20or\x20is\x20unset,\x20the\x20go\x20command\x20runs\x20in\x20module-aware\x0amode\x20if\x20a\x20go.mod\x20file\x20is\x20present\x20in\x20the\x20current\x20directory\x20or\x20any\x20parent\x0adirectory\x20(the\x20default\x20behavior).
  • \x0a
\x0a

In\x20module-aware\x20mode,\x20GOPATH\x20no\x20longer\x20defines\x20the\x20meaning\x20of\x20imports\x20during\x20a\x0abuild,\x20but\x20it\x20still\x20stores\x20downloaded\x20dependencies\x20(in\x20GOPATH/pkg/mod;\x20see\x0aModule\x20cache)\x20and\x20installed\x20commands\x20(in\x20GOPATH/bin,\x20unless\x0aGOBIN\x20is\x20set).

\x0aBuild\x20commands\x0a

All\x20commands\x20that\x20load\x20information\x20about\x20packages\x20are\x20module-aware.\x20This\x0aincludes:

\x0a
    \x0a
  • go\x20build
  • \x0a
  • go\x20fix
  • \x0a
  • go\x20generate
  • \x0a
  • go\x20get
  • \x0a
  • go\x20install
  • \x0a
  • go\x20list
  • \x0a
  • go\x20run
  • \x0a
  • go\x20test
  • \x0a
  • go\x20vet
  • \x0a
\x0a

When\x20run\x20in\x20module-aware\x20mode,\x20these\x20commands\x20use\x20go.mod\x20files\x20to\x20interpret\x0aimport\x20paths\x20listed\x20on\x20the\x20command\x20line\x20or\x20written\x20in\x20Go\x20source\x20files.\x20These\x0acommands\x20accept\x20the\x20following\x20flags,\x20common\x20to\x20all\x20module\x20commands.

\x0a
    \x0a
  • The\x20-mod\x20flag\x20controls\x20whether\x20go.mod\x20may\x20be\x20automatically\x20updated\x20and\x0awhether\x20the\x20vendor\x20directory\x20is\x20used.\x0a
      \x0a
    • -mod=mod\x20tells\x20the\x20go\x20command\x20to\x20ignore\x20the\x20vendor\x20directory\x20and\x20to\x0aautomatically\x20update\x20go.mod,\x20for\x20example,\x20when\x20an\x0aimported\x20package\x20is\x20not\x20provided\x20by\x20any\x20known\x20module.
    • \x0a
    • -mod=readonly\x20tells\x20the\x20go\x20command\x20to\x20ignore\x20the\x20vendor\x20directory\x20and\x0ato\x20report\x20an\x20error\x20if\x20go.mod\x20needs\x20to\x20be\x20updated.
    • \x0a
    • -mod=vendor\x20tells\x20the\x20go\x20command\x20to\x20use\x20the\x20vendor\x20directory.\x20In\x20this\x0amode,\x20the\x20go\x20command\x20will\x20not\x20use\x20the\x20network\x20or\x20the\x20module\x20cache.
    • \x0a
    • By\x20default,\x20if\x20the\x20go\x20version\x20in\x20go.mod\x20is\x201.14\x20or\x0ahigher\x20and\x20a\x20vendor\x20directory\x20is\x20present,\x20the\x20go\x20command\x20will\x20act\x20as\x20if\x0a-mod=vendor\x20were\x20used.\x20Otherwise,\x20the\x20go\x20command\x20will\x20act\x20as\x20if\x0a-mod=mod\x20were\x20used.
    • \x0a
    \x0a
  • \x0a
  • The\x20-modcacherw\x20flag\x20instructs\x20the\x20go\x20command\x20to\x20create\x20new\x20directories\x0ain\x20the\x20module\x20cache\x20with\x20read-write\x20permissions\x20instead\x20of\x20making\x20them\x0aread-only.\x20When\x20this\x20flag\x20is\x20used\x20consistently\x20(typically\x20by\x20setting\x0aGOFLAGS=-modcacherw\x20in\x20the\x20environment\x20or\x20by\x20running\x0ago\x20env\x20-w\x20GOFLAGS=-modcacherw),\x20the\x20module\x20cache\x20may\x20be\x20deleted\x20with\x0acommands\x20like\x20rm\x20-r\x20without\x20changing\x20permissions\x20first.\x20The\x0ago\x20clean\x20-modcache\x20command\x20may\x20be\x20used\x20to\x20delete\x20the\x0amodule\x20cache,\x20whether\x20or\x20not\x20-modcacherw\x20was\x20used.
  • \x0a
  • The\x20-modfile=file.mod\x20flag\x20instructs\x20the\x20go\x20command\x20to\x20read\x20(and\x20possibly\x0awrite)\x20an\x20alternate\x20file\x20instead\x20of\x20go.mod\x20in\x20the\x20module\x20root\x20directory.\x20The\x0afile's\x20name\x20must\x20end\x20with\x20.mod.\x20A\x20file\x20named\x20go.mod\x20must\x20still\x20be\x20present\x0ain\x20order\x20to\x20determine\x20the\x20module\x20root\x20directory,\x20but\x20it\x20is\x20not\x20accessed.\x20When\x0a-modfile\x20is\x20specified,\x20an\x20alternate\x20go.sum\x20file\x20is\x20also\x20used:\x20its\x20path\x20is\x0aderived\x20from\x20the\x20-modfile\x20flag\x20by\x20trimming\x20the\x20.mod\x20extension\x20and\x0aappending\x20.sum.
  • \x0a
\x0aVendoring\x0a

When\x20using\x20modules,\x20the\x20go\x20command\x20typically\x20satisfies\x20dependencies\x20by\x0adownloading\x20modules\x20from\x20their\x20sources\x20into\x20the\x20module\x20cache,\x20then\x20loading\x0apackages\x20from\x20those\x20downloaded\x20copies.\x20Vendoring\x20may\x20be\x20used\x20to\x20allow\x0ainteroperation\x20with\x20older\x20versions\x20of\x20Go,\x20or\x20to\x20ensure\x20that\x20all\x20files\x20used\x20for\x20a\x0abuild\x20are\x20stored\x20in\x20a\x20single\x20file\x20tree.

\x0a

The\x20go\x20mod\x20vendor\x20command\x20constructs\x20a\x20directory\x20named\x20vendor\x20in\x20the\x20main\x0amodule's\x20root\x20directory\x20containing\x20copies\x20of\x20all\x20packages\x0aneeded\x20to\x20build\x20and\x20test\x20packages\x20in\x20the\x20main\x20module.\x20Packages\x20that\x20are\x20only\x0aimported\x20by\x20tests\x20of\x20packages\x20outside\x20the\x20main\x20module\x20are\x20not\x20included.\x20As\x20with\x0ago\x20mod\x20tidy\x20and\x20other\x20module\x20commands,\x20build\x0aconstraints\x20except\x20for\x20ignore\x20are\x20not\x20considered\x20when\x0aconstructing\x20the\x20vendor\x20directory.

\x0a

go\x20mod\x20vendor\x20also\x20creates\x20the\x20file\x20vendor/modules.txt\x20that\x20contains\x20a\x20list\x0aof\x20vendored\x20packages\x20and\x20the\x20module\x20versions\x20they\x20were\x20copied\x20from.\x20When\x0avendoring\x20is\x20enabled,\x20this\x20manifest\x20is\x20used\x20as\x20a\x20source\x20of\x20module\x20version\x0ainformation,\x20as\x20reported\x20by\x20go\x20list\x20-m\x20and\x20go\x20version\x20-m.\x20When\x20the\x20go\x20command\x20reads\x20vendor/modules.txt,\x20it\x20checks\x0athat\x20the\x20module\x20versions\x20are\x20consistent\x20with\x20go.mod.\x20If\x20go.mod\x20has\x20changed\x0asince\x20vendor/modules.txt\x20was\x20generated,\x20the\x20go\x20command\x20will\x20report\x20an\x20error.\x0ago\x20mod\x20vendor\x20should\x20be\x20run\x20again\x20to\x20update\x20the\x20vendor\x20directory.

\x0a

If\x20the\x20vendor\x20directory\x20is\x20present\x20in\x20the\x20main\x20module's\x20root\x20directory,\x20it\x0awill\x20be\x20used\x20automatically\x20if\x20the\x20go\x20version\x20in\x20the\x20main\x0amodule's\x20go.mod\x20file\x20is\x201.14\x20or\x20higher.\x20To\x20explicitly\x0aenable\x20vendoring,\x20invoke\x20the\x20go\x20command\x20with\x20the\x20flag\x20-mod=vendor.\x20To\x0adisable\x20vendoring,\x20use\x20the\x20flag\x20-mod=mod.

\x0a

When\x20vendoring\x20is\x20enabled,\x20build\x20commands\x20like\x20go\x20build\x20and\x0ago\x20test\x20load\x20packages\x20from\x20the\x20vendor\x20directory\x20instead\x20of\x20accessing\x20the\x0anetwork\x20or\x20the\x20local\x20module\x20cache.\x20The\x20go\x20list\x20-m\x20command\x20only\x0aprints\x20information\x20about\x20modules\x20listed\x20in\x20go.mod.\x20go\x20mod\x20commands\x20such\x20as\x0ago\x20mod\x20download\x20and\x20go\x20mod\x20tidy\x20do\x20not\x0awork\x20differently\x20when\x20vendoring\x20is\x20enabled\x20and\x20will\x20still\x20download\x20modules\x20and\x0aaccess\x20the\x20module\x20cache.\x20go\x20get\x20also\x20does\x20not\x20work\x20differently\x20when\x0avendoring\x20is\x20enabled.

\x0a

Unlike\x20vendoring\x20in\x20GOPATH,\x20the\x20go\x0acommand\x20ignores\x20vendor\x20directories\x20in\x20locations\x20other\x20than\x20the\x20main\x20module's\x0aroot\x20directory.

\x0ago\x20get\x0a

Usage:

\x0a
go\x20get\x20[-d]\x20[-t]\x20[-u]\x20[build\x20flags]\x20[packages]\x0a
\x0a

Examples:

\x0a
#\x20Install\x20the\x20latest\x20version\x20of\x20a\x20tool.\x0a$\x20go\x20get\x20golang.org/x/tools/cmd/goimports\x0a\x0a#\x20Upgrade\x20a\x20specific\x20module.\x0a$\x20go\x20get\x20-d\x20golang.org/x/net\x0a\x0a#\x20Upgrade\x20modules\x20that\x20provide\x20packages\x20imported\x20by\x20packages\x20in\x20the\x20main\x20module.\x0a$\x20go\x20get\x20-d\x20-u\x20./...\x0a\x0a#\x20Upgrade\x20or\x20downgrade\x20to\x20a\x20specific\x20version\x20of\x20a\x20module.\x0a$\x20go\x20get\x20-d\x20golang.org/x/text@v0.3.2\x0a\x0a#\x20Update\x20to\x20the\x20commit\x20on\x20the\x20module's\x20master\x20branch.\x0a$\x20go\x20get\x20-d\x20golang.org/x/text@master\x0a\x0a#\x20Remove\x20a\x20dependency\x20on\x20a\x20module\x20and\x20downgrade\x20modules\x20that\x20require\x20it\x0a#\x20to\x20versions\x20that\x20don't\x20require\x20it.\x0a$\x20go\x20get\x20-d\x20golang.org/x/text@none\x0a
\x0a

The\x20go\x20get\x20command\x20updates\x20module\x20dependencies\x20in\x20the\x20go.mod\x0afile\x20for\x20the\x20main\x20module,\x20then\x20builds\x20and\x0ainstalls\x20packages\x20listed\x20on\x20the\x20command\x20line.

\x0a

The\x20first\x20step\x20is\x20to\x20determine\x20which\x20modules\x20to\x20update.\x20go\x20get\x20accepts\x20a\x20list\x0aof\x20packages,\x20package\x20patterns,\x20and\x20module\x20paths\x20as\x20arguments.\x20If\x20a\x20package\x0aargument\x20is\x20specified,\x20go\x20get\x20updates\x20the\x20module\x20that\x20provides\x20the\x20package.\x0aIf\x20a\x20package\x20pattern\x20is\x20specified\x20(for\x20example,\x20all\x20or\x20a\x20path\x20with\x20a\x20...\x0awildcard),\x20go\x20get\x20expands\x20the\x20pattern\x20to\x20a\x20set\x20of\x20packages,\x20then\x20updates\x20the\x0amodules\x20that\x20provide\x20the\x20packages.\x20If\x20an\x20argument\x20names\x20a\x20module\x20but\x20not\x20a\x0apackage\x20(for\x20example,\x20the\x20module\x20golang.org/x/net\x20has\x20no\x20package\x20in\x20its\x20root\x0adirectory),\x20go\x20get\x20will\x20update\x20the\x20module\x20but\x20will\x20not\x20build\x20a\x20package.\x20If\x20no\x0aarguments\x20are\x20specified,\x20go\x20get\x20acts\x20as\x20if\x20.\x20were\x20specified\x20(the\x20package\x20in\x0athe\x20current\x20directory);\x20this\x20may\x20be\x20used\x20together\x20with\x20the\x20-u\x20flag\x20to\x20update\x0amodules\x20that\x20provide\x20imported\x20packages.

\x0a

Each\x20argument\x20may\x20include\x20a\x20version\x20query\x20suffix\x20indicating\x20the\x0adesired\x20version,\x20as\x20in\x20go\x20get\x20golang.org/x/text@v0.3.0.\x20A\x20version\x20query\x0asuffix\x20consists\x20of\x20an\x20@\x20symbol\x20followed\x20by\x20a\x20version\x20query,\x0awhich\x20may\x20indicate\x20a\x20specific\x20version\x20(v0.3.0),\x20a\x20version\x20prefix\x20(v0.3),\x0aa\x20branch\x20or\x20tag\x20name\x20(master),\x20a\x20revision\x20(1234abcd),\x20or\x20one\x20of\x20the\x20special\x0aqueries\x20latest,\x20upgrade,\x20patch,\x20or\x20none.\x20If\x20no\x20version\x20is\x20given,\x0ago\x20get\x20uses\x20the\x20@upgrade\x20query.

\x0a

Once\x20go\x20get\x20has\x20resolved\x20its\x20arguments\x20to\x20specific\x20modules\x20and\x20versions,\x20go\x20get\x20will\x20add,\x20change,\x20or\x20remove\x20require\x20directives\x20in\x20the\x0amain\x20module's\x20go.mod\x20file\x20to\x20ensure\x20the\x20modules\x20remain\x20at\x20the\x20desired\x0aversions\x20in\x20the\x20future.\x20Note\x20that\x20required\x20versions\x20in\x20go.mod\x20files\x20are\x0aminimum\x20versions\x20and\x20may\x20be\x20increased\x20automatically\x20as\x20new\x20dependencies\x20are\x0aadded.\x20See\x20Minimal\x20version\x20selection\x20(MVS)\x20for\x0adetails\x20on\x20how\x20versions\x20are\x20selected\x20and\x20conflicts\x20are\x20resolved\x20by\x20module-aware\x0acommands.

\x0a

Other\x20modules\x20may\x20be\x20upgraded\x20when\x20a\x20module\x20named\x20on\x20the\x20command\x20line\x20is\x20added,\x0aupgraded,\x20or\x20downgraded\x20if\x20the\x20new\x20version\x20of\x20the\x20named\x20module\x20requires\x20other\x0amodules\x20at\x20higher\x20versions.\x20For\x20example,\x20suppose\x20module\x20example.com/a\x20is\x0aupgraded\x20to\x20version\x20v1.5.0,\x20and\x20that\x20version\x20requires\x20module\x20example.com/b\x0aat\x20version\x20v1.2.0.\x20If\x20module\x20example.com/b\x20is\x20currently\x20required\x20at\x20version\x0av1.1.0,\x20go\x20get\x20example.com/a@v1.5.0\x20will\x20also\x20upgrade\x20example.com/b\x20to\x0av1.2.0.

\x0a

\x0a

Other\x20modules\x20may\x20be\x20downgraded\x20when\x20a\x20module\x20named\x20on\x20the\x20command\x20line\x20is\x0adowngraded\x20or\x20removed.\x20To\x20continue\x20the\x20above\x20example,\x20suppose\x20module\x0aexample.com/b\x20is\x20downgraded\x20to\x20v1.1.0.\x20Module\x20example.com/a\x20would\x20also\x20be\x0adowngraded\x20to\x20a\x20version\x20that\x20requires\x20example.com/b\x20at\x20version\x20v1.1.0\x20or\x0alower.

\x0a

\x0a

A\x20module\x20requirement\x20may\x20be\x20removed\x20using\x20the\x20version\x20suffix\x20@none.\x20This\x20is\x20a\x0aspecial\x20kind\x20of\x20downgrade.\x20Modules\x20that\x20depend\x20on\x20the\x20removed\x20module\x20will\x20be\x0adowngraded\x20or\x20removed\x20as\x20needed.\x20A\x20module\x20requirement\x20may\x20be\x20removed\x20even\x20if\x20one\x0aor\x20more\x20of\x20its\x20packages\x20are\x20imported\x20by\x20packages\x20in\x20the\x20main\x20module.\x20In\x20this\x0acase,\x20the\x20next\x20build\x20command\x20may\x20add\x20a\x20new\x20module\x20requirement.

\x0a

If\x20a\x20module\x20is\x20needed\x20at\x20two\x20different\x20versions\x20(specified\x20explicitly\x20in\x20command\x0aline\x20arguments\x20or\x20to\x20satisfy\x20upgrades\x20and\x20downgrades),\x20go\x20get\x20will\x20report\x20an\x0aerror.

\x0a

After\x20go\x20get\x20updates\x20the\x20go.mod\x20file,\x20it\x20builds\x20the\x20packages\x20named\x0aon\x20the\x20command\x20line.\x20Executables\x20will\x20be\x20installed\x20in\x20the\x20directory\x20named\x20by\x0athe\x20GOBIN\x20environment\x20variable,\x20which\x20defaults\x20to\x20$GOPATH/bin\x20or\x0a$HOME/go/bin\x20if\x20the\x20GOPATH\x20environment\x20variable\x20is\x20not\x20set.

\x0a

go\x20get\x20supports\x20the\x20following\x20flags:

\x0a
    \x0a
  • The\x20-d\x20flag\x20tells\x20go\x20get\x20not\x20to\x20build\x20or\x20install\x20packages.\x20When\x20-d\x20is\x0aused,\x20go\x20get\x20will\x20only\x20manage\x20dependencies\x20in\x20go.mod.
  • \x0a
  • The\x20-u\x20flag\x20tells\x20go\x20get\x20to\x20upgrade\x20modules\x20providing\x20packages\x0aimported\x20directly\x20or\x20indirectly\x20by\x20packages\x20named\x20on\x20the\x20command\x20line.\x0aEach\x20module\x20selected\x20by\x20-u\x20will\x20be\x20upgraded\x20to\x20its\x20latest\x20version\x20unless\x0ait\x20is\x20already\x20required\x20at\x20a\x20higher\x20version\x20(a\x20pre-release).
  • \x0a
  • The\x20-u=patch\x20flag\x20(not\x20-u\x20patch)\x20also\x20tells\x20go\x20get\x20to\x20upgrade\x0adependencies,\x20but\x20go\x20get\x20will\x20upgrade\x20each\x20dependency\x20to\x20the\x20latest\x20patch\x0aversion\x20(similar\x20to\x20the\x20@patch\x20version\x20query).
  • \x0a
  • The\x20-t\x20flag\x20tells\x20go\x20get\x20to\x20consider\x20modules\x20needed\x20to\x20build\x20tests\x0aof\x20packages\x20named\x20on\x20the\x20command\x20line.\x20When\x20-t\x20and\x20-u\x20are\x20used\x20together,\x0ago\x20get\x20will\x20update\x20test\x20dependencies\x20as\x20well.
  • \x0a
  • The\x20-insecure\x20flag\x20should\x20no\x20longer\x20be\x20used.\x20It\x20permits\x20go\x20get\x20to\x20resolve\x0acustom\x20import\x20paths\x20and\x20fetch\x20from\x20repositories\x20and\x20module\x20proxies\x20using\x0ainsecure\x20schemes\x20such\x20as\x20HTTP.\x20The\x20GOINSECURE\x20environment\x0avariable\x20provides\x20more\x20fine-grained\x20control\x20and\x0ashould\x20be\x20used\x20instead.
  • \x0a
\x0ago\x20list\x20-m\x0a

Usage:

\x0a
go\x20list\x20-m\x20[-u]\x20[-versions]\x20[list\x20flags]\x20[modules]\x0a
\x0a

Example:

\x0a
$\x20go\x20list\x20-m\x20all\x0a$\x20go\x20list\x20-m\x20-versions\x20example.com/m\x0a$\x20go\x20list\x20-m\x20-json\x20example.com/m@latest\x0a
\x0a

The\x20-m\x20flag\x20causes\x20go\x20list\x20to\x20list\x20modules\x20instead\x20of\x20packages.\x20In\x20this\x0amode,\x20the\x20arguments\x20to\x20go\x20list\x20may\x20be\x20modules,\x20module\x20patterns\x20(containing\x20the\x0a...\x20wildcard),\x20version\x20queries,\x20or\x20the\x20special\x20pattern\x0aall,\x20which\x20matches\x20all\x20modules\x20in\x20the\x20build\x20list.\x20If\x20no\x0aarguments\x20are\x20specified,\x20the\x20main\x20module\x20is\x20listed.

\x0a

When\x20listing\x20modules,\x20the\x20-f\x20flag\x20still\x20specifies\x20a\x20format\x20template\x20applied\x0ato\x20a\x20Go\x20struct,\x20but\x20now\x20a\x20Module\x20struct:

\x0a
type\x20Module\x20struct\x20{\x0a\x20\x20\x20\x20Path\x20\x20\x20\x20\x20\x20string\x20\x20\x20\x20\x20\x20\x20//\x20module\x20path\x0a\x20\x20\x20\x20Version\x20\x20\x20string\x20\x20\x20\x20\x20\x20\x20//\x20module\x20version\x0a\x20\x20\x20\x20Versions\x20\x20[]string\x20\x20\x20\x20\x20//\x20available\x20module\x20versions\x20(with\x20-versions)\x0a\x20\x20\x20\x20Replace\x20\x20\x20*Module\x20\x20\x20\x20\x20\x20//\x20replaced\x20by\x20this\x20module\x0a\x20\x20\x20\x20Time\x20\x20\x20\x20\x20\x20*time.Time\x20\x20\x20//\x20time\x20version\x20was\x20created\x0a\x20\x20\x20\x20Update\x20\x20\x20\x20*Module\x20\x20\x20\x20\x20\x20//\x20available\x20update,\x20if\x20any\x20(with\x20-u)\x0a\x20\x20\x20\x20Main\x20\x20\x20\x20\x20\x20bool\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20is\x20this\x20the\x20main\x20module?\x0a\x20\x20\x20\x20Indirect\x20\x20bool\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20is\x20this\x20module\x20only\x20an\x20indirect\x20dependency\x20of\x20main\x20module?\x0a\x20\x20\x20\x20Dir\x20\x20\x20\x20\x20\x20\x20string\x20\x20\x20\x20\x20\x20\x20//\x20directory\x20holding\x20files\x20for\x20this\x20module,\x20if\x20any\x0a\x20\x20\x20\x20GoMod\x20\x20\x20\x20\x20string\x20\x20\x20\x20\x20\x20\x20//\x20path\x20to\x20go.mod\x20file\x20for\x20this\x20module,\x20if\x20any\x0a\x20\x20\x20\x20GoVersion\x20string\x20\x20\x20\x20\x20\x20\x20//\x20go\x20version\x20used\x20in\x20module\x0a\x20\x20\x20\x20Error\x20\x20\x20\x20\x20*ModuleError\x20//\x20error\x20loading\x20module\x0a}\x0a\x0atype\x20ModuleError\x20struct\x20{\x0a\x20\x20\x20\x20Err\x20string\x20//\x20the\x20error\x20itself\x0a}\x0a
\x0a

The\x20default\x20output\x20is\x20to\x20print\x20the\x20module\x20path\x20and\x20then\x20information\x20about\x20the\x0aversion\x20and\x20replacement\x20if\x20any.\x20For\x20example,\x20go\x20list\x20-m\x20all\x20might\x20print:

\x0a
example.com/main/module\x0agolang.org/x/text\x20v0.3.0\x20=>\x20/tmp/text\x0arsc.io/pdf\x20v0.1.1\x0a
\x0a

The\x20Module\x20struct\x20has\x20a\x20String\x20method\x20that\x20formats\x20this\x20line\x20of\x20output,\x20so\x0athat\x20the\x20default\x20format\x20is\x20equivalent\x20to\x20-f\x20'{{.String}}'.

\x0a

Note\x20that\x20when\x20a\x20module\x20has\x20been\x20replaced,\x20its\x20Replace\x20field\x20describes\x20the\x0areplacement\x20module\x20module,\x20and\x20its\x20Dir\x20field\x20is\x20set\x20to\x20the\x20replacement\x0amodule's\x20source\x20code,\x20if\x20present.\x20(That\x20is,\x20if\x20Replace\x20is\x20non-nil,\x20then\x20Dir\x0ais\x20set\x20to\x20Replace.Dir,\x20with\x20no\x20access\x20to\x20the\x20replaced\x20source\x20code.)

\x0a

The\x20-u\x20flag\x20adds\x20information\x20about\x20available\x20upgrades.\x20When\x20the\x20latest\x20version\x0aof\x20a\x20given\x20module\x20is\x20newer\x20than\x20the\x20current\x20one,\x20list\x20-u\x20sets\x20the\x20module's\x0aUpdate\x20field\x20to\x20information\x20about\x20the\x20newer\x20module.\x20The\x20module's\x20String\x0amethod\x20indicates\x20an\x20available\x20upgrade\x20by\x20formatting\x20the\x20newer\x20version\x20in\x0abrackets\x20after\x20the\x20current\x20version.\x20For\x20example,\x20go\x20list\x20-m\x20-u\x20all\x20might\x0aprint:

\x0a
example.com/main/module\x0agolang.org/x/text\x20v0.3.0\x20[v0.4.0]\x20=>\x20/tmp/text\x0arsc.io/pdf\x20v0.1.1\x20[v0.1.2]\x0a
\x0a

(For\x20tools,\x20go\x20list\x20-m\x20-u\x20-json\x20all\x20may\x20be\x20more\x20convenient\x20to\x20parse.)

\x0a

The\x20-versions\x20flag\x20causes\x20list\x20to\x20set\x20the\x20module's\x20Versions\x20field\x20to\x20a\x0alist\x20of\x20all\x20known\x20versions\x20of\x20that\x20module,\x20ordered\x20according\x20to\x20semantic\x0aversioning,\x20lowest\x20to\x20highest.\x20The\x20flag\x20also\x20changes\x20the\x20default\x20output\x20format\x0ato\x20display\x20the\x20module\x20path\x20followed\x20by\x20the\x20space-separated\x20version\x20list.

\x0a

The\x20template\x20function\x20module\x20takes\x20a\x20single\x20string\x20argument\x20that\x20must\x20be\x20a\x0amodule\x20path\x20or\x20query\x20and\x20returns\x20the\x20specified\x20module\x20as\x20a\x20Module\x20struct.\x20If\x0aan\x20error\x20occurs,\x20the\x20result\x20will\x20be\x20a\x20Module\x20struct\x20with\x20a\x20non-nil\x20Error\x0afield.

\x0ago\x20mod\x20download\x0a

Usage:

\x0a
go\x20mod\x20download\x20[-json]\x20[-x]\x20[modules]\x0a
\x0a

Example:

\x0a
$\x20go\x20mod\x20download\x0a$\x20go\x20mod\x20download\x20golang.org/x/mod@v0.2.0\x0a
\x0a

The\x20go\x20mod\x20download\x20command\x20downloads\x20the\x20named\x20modules\x20into\x20the\x20module\x0acache.\x20Arguments\x20can\x20be\x20module\x20paths\x20or\x20module\x0apatterns\x20selecting\x20dependencies\x20of\x20the\x20main\x20module\x20or\x20version\x0aqueries\x20of\x20the\x20form\x20path@version.\x20With\x20no\x20arguments,\x0adownload\x20applies\x20to\x20all\x20dependencies\x20of\x20the\x20main\x20module.

\x0a

The\x20go\x20command\x20will\x20automatically\x20download\x20modules\x20as\x20needed\x20during\x20ordinary\x0aexecution.\x20The\x20go\x20mod\x20download\x20command\x20is\x20useful\x20mainly\x20for\x20pre-filling\x20the\x0amodule\x20cache\x20or\x20for\x20loading\x20data\x20to\x20be\x20served\x20by\x20a\x20module\x0aproxy.

\x0a

By\x20default,\x20download\x20writes\x20nothing\x20to\x20standard\x20output.\x20It\x20prints\x20progress\x0amessages\x20and\x20errors\x20to\x20standard\x20error.

\x0a

The\x20-json\x20flag\x20causes\x20download\x20to\x20print\x20a\x20sequence\x20of\x20JSON\x20objects\x20to\x0astandard\x20output,\x20describing\x20each\x20downloaded\x20module\x20(or\x20failure),\x20corresponding\x0ato\x20this\x20Go\x20struct:

\x0a
type\x20Module\x20struct\x20{\x0a\x20\x20\x20\x20Path\x20\x20\x20\x20\x20string\x20//\x20module\x20path\x0a\x20\x20\x20\x20Version\x20\x20string\x20//\x20module\x20version\x0a\x20\x20\x20\x20Error\x20\x20\x20\x20string\x20//\x20error\x20loading\x20module\x0a\x20\x20\x20\x20Info\x20\x20\x20\x20\x20string\x20//\x20absolute\x20path\x20to\x20cached\x20.info\x20file\x0a\x20\x20\x20\x20GoMod\x20\x20\x20\x20string\x20//\x20absolute\x20path\x20to\x20cached\x20.mod\x20file\x0a\x20\x20\x20\x20Zip\x20\x20\x20\x20\x20\x20string\x20//\x20absolute\x20path\x20to\x20cached\x20.zip\x20file\x0a\x20\x20\x20\x20Dir\x20\x20\x20\x20\x20\x20string\x20//\x20absolute\x20path\x20to\x20cached\x20source\x20root\x20directory\x0a\x20\x20\x20\x20Sum\x20\x20\x20\x20\x20\x20string\x20//\x20checksum\x20for\x20path,\x20version\x20(as\x20in\x20go.sum)\x0a\x20\x20\x20\x20GoModSum\x20string\x20//\x20checksum\x20for\x20go.mod\x20(as\x20in\x20go.sum)\x0a}\x0a
\x0a

The\x20-x\x20flag\x20causes\x20download\x20to\x20print\x20the\x20commands\x20download\x20executes\x0ato\x20standard\x20error.

\x0ago\x20mod\x20edit\x0a

Usage:

\x0a
go\x20mod\x20edit\x20[editing\x20flags]\x20[-fmt|-print|-json]\x20[go.mod]\x0a
\x0a

Example:

\x0a
#\x20Add\x20a\x20replace\x20directive.\x0a$\x20go\x20mod\x20edit\x20-replace\x20example.com/a@v1.0.0=./a\x0a\x0a#\x20Remove\x20a\x20replace\x20directive.\x0a$\x20go\x20mod\x20edit\x20-dropreplace\x20example.com/a@v1.0.0\x0a\x0a#\x20Set\x20the\x20go\x20version,\x20add\x20a\x20requirement,\x20and\x20print\x20the\x20file\x0a#\x20instead\x20of\x20writing\x20it\x20to\x20disk.\x0a$\x20go\x20mod\x20edit\x20-go=1.14\x20-require=example.com/m@v1.0.0\x20-print\x0a\x0a#\x20Format\x20the\x20go.mod\x20file.\x0a$\x20go\x20mod\x20edit\x20-fmt\x0a\x0a#\x20Format\x20and\x20print\x20a\x20different\x20.mod\x20file.\x0a$\x20go\x20mod\x20edit\x20-print\x20tools.mod\x0a\x0a#\x20Print\x20a\x20JSON\x20representation\x20of\x20the\x20go.mod\x20file.\x0a$\x20go\x20mod\x20edit\x20-json\x0a
\x0a

The\x20go\x20mod\x20edit\x20command\x20provides\x20a\x20command-line\x20interface\x20for\x20editing\x20and\x0aformatting\x20go.mod\x20files,\x20for\x20use\x20primarily\x20by\x20tools\x20and\x20scripts.\x20go\x20mod\x20edit\x0areads\x20only\x20one\x20go.mod\x20file;\x20it\x20does\x20not\x20look\x20up\x20information\x20about\x20other\x0amodules.\x20By\x20default,\x20go\x20mod\x20edit\x20reads\x20and\x20writes\x20the\x20go.mod\x20file\x20of\x20the\x0amain\x20module,\x20but\x20a\x20different\x20target\x20file\x20can\x20be\x20specified\x20after\x20the\x20editing\x0aflags.

\x0a

The\x20editing\x20flags\x20specify\x20a\x20sequence\x20of\x20editing\x20operations.

\x0a
    \x0a
  • The\x20-module\x20flag\x20changes\x20the\x20module's\x20path\x20(the\x20go.mod\x20file's\x20module\x0aline).
  • \x0a
  • The\x20-go=version\x20flag\x20sets\x20the\x20expected\x20Go\x20language\x20version.
  • \x0a
  • The\x20-require=path@version\x20and\x20-droprequire=path\x20flags\x20add\x20and\x20drop\x20a\x0arequirement\x20on\x20the\x20given\x20module\x20path\x20and\x20version.\x20Note\x20that\x20-require\x0aoverrides\x20any\x20existing\x20requirements\x20on\x20path.\x20These\x20flags\x20are\x20mainly\x20for\x0atools\x20that\x20understand\x20the\x20module\x20graph.\x20Users\x20should\x20prefer\x20go\x20get\x20path@version\x20or\x20go\x20get\x20path@none,\x20which\x20make\x20other\x20go.mod\x20adjustments\x20as\x0aneeded\x20to\x20satisfy\x20constraints\x20imposed\x20by\x20other\x20modules.\x20See\x20go\x20get.
  • \x0a
  • The\x20-exclude=path@version\x20and\x20-dropexclude=path@version\x20flags\x20add\x20and\x20drop\x0aan\x20exclusion\x20for\x20the\x20given\x20module\x20path\x20and\x20version.\x20Note\x20that\x0a-exclude=path@version\x20is\x20a\x20no-op\x20if\x20that\x20exclusion\x20already\x20exists.
  • \x0a
  • The\x20-replace=old[@v]=new[@v]\x20flag\x20adds\x20a\x20replacement\x20of\x20the\x20given\x20module\x0apath\x20and\x20version\x20pair.\x20If\x20the\x20@v\x20in\x20old@v\x20is\x20omitted,\x20a\x20replacement\x0awithout\x20a\x20version\x20on\x20the\x20left\x20side\x20is\x20added,\x20which\x20applies\x20to\x20all\x20versions\x20of\x0athe\x20old\x20module\x20path.\x20If\x20the\x20@v\x20in\x20new@v\x20is\x20omitted,\x20the\x20new\x20path\x20should\x20be\x0aa\x20local\x20module\x20root\x20directory,\x20not\x20a\x20module\x20path.\x20Note\x20that\x20-replace\x0aoverrides\x20any\x20redundant\x20replacements\x20for\x20old[@v],\x20so\x20omitting\x20@v\x20will\x20drop\x0areplacements\x20for\x20specific\x20versions.
  • \x0a
  • The\x20-dropreplace=old[@v]\x20flag\x20drops\x20a\x20replacement\x20of\x20the\x20given\x20module\x20path\x0aand\x20version\x20pair.\x20If\x20the\x20@v\x20is\x20provided,\x20a\x20replacement\x20with\x20the\x20given\x0aversion\x20is\x20dropped.\x20An\x20existing\x20replacement\x20without\x20a\x20version\x20on\x20the\x20left\x20side\x0amay\x20still\x20replace\x20the\x20module.\x20If\x20the\x20@v\x20is\x20omitted,\x20a\x20replacement\x20without\x20a\x0aversion\x20is\x20dropped.
  • \x0a
\x0a

The\x20editing\x20flags\x20may\x20be\x20repeated.\x20The\x20changes\x20are\x20applied\x20in\x20the\x20order\x20given.

\x0a

go\x20mod\x20edit\x20has\x20additional\x20flags\x20that\x20control\x20its\x20output.

\x0a
    \x0a
  • The\x20-fmt\x20flag\x20reformats\x20the\x20go.mod\x20file\x20without\x20making\x20other\x20changes.\x0aThis\x20reformatting\x20is\x20also\x20implied\x20by\x20any\x20other\x20modifications\x20that\x20use\x20or\x0arewrite\x20the\x20go.mod\x20file.\x20The\x20only\x20time\x20this\x20flag\x20is\x20needed\x20is\x20if\x20no\x0aother\x20flags\x20are\x20specified,\x20as\x20in\x20go\x20mod\x20edit\x20-fmt.
  • \x0a
  • The\x20-print\x20flag\x20prints\x20the\x20final\x20go.mod\x20in\x20its\x20text\x20format\x20instead\x20of\x0awriting\x20it\x20back\x20to\x20disk.
  • \x0a
  • The\x20-json\x20flag\x20prints\x20the\x20final\x20go.mod\x20in\x20JSON\x20format\x20instead\x20of\x20writing\x0ait\x20back\x20to\x20disk\x20in\x20text\x20format.\x20The\x20JSON\x20output\x20corresponds\x20to\x20these\x20Go\x20types:
  • \x0a
\x0a
type\x20Module\x20struct\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20Path\x20string\x0a\x20\x20\x20\x20\x20\x20\x20\x20Version\x20string\x0a}\x0a\x0atype\x20GoMod\x20struct\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20Module\x20\x20Module\x0a\x20\x20\x20\x20\x20\x20\x20\x20Go\x20\x20\x20\x20\x20\x20string\x0a\x20\x20\x20\x20\x20\x20\x20\x20Require\x20[]Require\x0a\x20\x20\x20\x20\x20\x20\x20\x20Exclude\x20[]Module\x0a\x20\x20\x20\x20\x20\x20\x20\x20Replace\x20[]Replace\x0a}\x0a\x0atype\x20Require\x20struct\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20Path\x20string\x0a\x20\x20\x20\x20\x20\x20\x20\x20Version\x20string\x0a\x20\x20\x20\x20\x20\x20\x20\x20Indirect\x20bool\x0a}\x0a\x0atype\x20Replace\x20struct\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20Old\x20Module\x0a\x20\x20\x20\x20\x20\x20\x20\x20New\x20Module\x0a}\x0a
\x0a

Note\x20that\x20this\x20only\x20describes\x20the\x20go.mod\x20file\x20itself,\x20not\x20other\x20modules\x0areferred\x20to\x20indirectly.\x20For\x20the\x20full\x20set\x20of\x20modules\x20available\x20to\x20a\x20build,\x0ause\x20go\x20list\x20-m\x20-json\x20all.\x20See\x20go\x20list\x20-m.

\x0a

For\x20example,\x20a\x20tool\x20can\x20obtain\x20the\x20go.mod\x20file\x20as\x20a\x20data\x20structure\x20by\x0aparsing\x20the\x20output\x20of\x20go\x20mod\x20edit\x20-json\x20and\x20can\x20then\x20make\x20changes\x20by\x20invoking\x0ago\x20mod\x20edit\x20with\x20-require,\x20-exclude,\x20and\x20so\x20on.

\x0a

Tools\x20may\x20also\x20use\x20the\x20package\x0agolang.org/x/mod/modfile\x0ato\x20parse,\x20edit,\x20and\x20format\x20go.mod\x20files.

\x0ago\x20mod\x20init\x0a

Usage:

\x0a
go\x20mod\x20init\x20[module-path]\x0a
\x0a

Example:

\x0a
go\x20mod\x20init\x0ago\x20mod\x20init\x20example.com/m\x0a
\x0a

The\x20go\x20mod\x20init\x20command\x20initializes\x20and\x20writes\x20a\x20new\x20go.mod\x20file\x20in\x20the\x0acurrent\x20directory,\x20in\x20effect\x20creating\x20a\x20new\x20module\x20rooted\x20at\x20the\x20current\x0adirectory.\x20The\x20go.mod\x20file\x20must\x20not\x20already\x20exist.

\x0a

init\x20accepts\x20one\x20optional\x20argument,\x20the\x20module\x20path\x20for\x0athe\x20new\x20module.\x20See\x20Module\x20paths\x20for\x20instructions\x20on\x20choosing\x0aa\x20module\x20path.\x20If\x20the\x20module\x20path\x20argument\x20is\x20omitted,\x20init\x20will\x20attempt\x0ato\x20infer\x20the\x20module\x20path\x20using\x20import\x20comments\x20in\x20.go\x20files,\x20vendoring\x20tool\x0aconfiguration\x20files,\x20and\x20the\x20current\x20directory\x20(if\x20in\x20GOPATH).

\x0a

If\x20a\x20configuration\x20file\x20for\x20a\x20vendoring\x20tool\x20is\x20present,\x20init\x20will\x20attempt\x20to\x0aimport\x20module\x20requirements\x20from\x20it.\x20init\x20supports\x20the\x20following\x20configuration\x0afiles.

\x0a
    \x0a
  • GLOCKFILE\x20(Glock)
  • \x0a
  • Godeps/Godeps.json\x20(Godeps)
  • \x0a
  • Gopkg.lock\x20(dep)
  • \x0a
  • dependencies.tsv\x20(godeps)
  • \x0a
  • glide.lock\x20(glide)
  • \x0a
  • vendor.conf\x20(trash)
  • \x0a
  • vendor.yml\x20(govend)
  • \x0a
  • vendor/manifest\x20(gvt)
  • \x0a
  • vendor/vendor.json\x20(govendor)
  • \x0a
\x0a

Vendoring\x20tool\x20configuration\x20files\x20can't\x20always\x20be\x20translated\x20with\x20perfect\x0afidelity.\x20For\x20example,\x20if\x20multiple\x20packages\x20within\x20the\x20same\x20repository\x20are\x0aimported\x20at\x20different\x20versions,\x20and\x20the\x20repository\x20only\x20contains\x20one\x20module,\x20the\x0aimported\x20go.mod\x20can\x20only\x20require\x20the\x20module\x20at\x20one\x20version.\x20You\x20may\x20wish\x20to\x0arun\x20go\x20list\x20-m\x20all\x20to\x20check\x20all\x20versions\x20in\x20the\x20build\x0alist,\x20and\x20go\x20mod\x20tidy\x20to\x20add\x20missing\x0arequirements\x20and\x20to\x20drop\x20unused\x20requirements.

\x0ago\x20mod\x20tidy\x0a

Usage:

\x0a
go\x20mod\x20tidy\x20[-v]\x0a
\x0a

go\x20mod\x20tidy\x20ensures\x20that\x20the\x20go.mod\x20file\x20matches\x20the\x20source\x20code\x20in\x20the\x0amodule.\x20It\x20adds\x20any\x20missing\x20module\x20requirements\x20necessary\x20to\x20build\x20the\x20current\x0amodule's\x20packages\x20and\x20dependencies,\x20and\x20it\x20removes\x20requirements\x20on\x20modules\x20that\x0adon't\x20provide\x20any\x20relevant\x20packages.\x20It\x20also\x20adds\x20any\x20missing\x20entries\x20to\x0ago.sum\x20and\x20removes\x20unnecessary\x20entries.

\x0a

The\x20-v\x20flag\x20causes\x20go\x20mod\x20tidy\x20to\x20print\x20information\x20about\x20removed\x20modules\x0ato\x20standard\x20error.

\x0a

go\x20mod\x20tidy\x20works\x20by\x20loading\x20all\x20of\x20the\x20packages\x20in\x20the\x20main\x0amodule\x20and\x20all\x20of\x20the\x20packages\x20they\x20import,\x0arecursively.\x20This\x20includes\x20packages\x20imported\x20by\x20tests\x20(including\x20tests\x20in\x20other\x0amodules).\x20go\x20mod\x20tidy\x20acts\x20as\x20if\x20all\x20build\x20tags\x20are\x20enabled,\x20so\x20it\x20will\x0aconsider\x20platform-specific\x20source\x20files\x20and\x20files\x20that\x20require\x20custom\x20build\x0atags,\x20even\x20if\x20those\x20source\x20files\x20wouldn't\x20normally\x20be\x20built.\x20There\x20is\x20one\x0aexception:\x20the\x20ignore\x20build\x20tag\x20is\x20not\x20enabled,\x20so\x20a\x20file\x20with\x20the\x20build\x0aconstraint\x20//\x20+build\x20ignore\x20will\x20not\x20be\x20considered.\x20Note\x20that\x20go\x20mod\x20tidy\x0awill\x20not\x20consider\x20packages\x20in\x20the\x20main\x20module\x20in\x20directories\x20named\x20testdata\x20or\x0awith\x20names\x20that\x20start\x20with\x20.\x20or\x20_\x20unless\x20those\x20packages\x20are\x20explicitly\x0aimported\x20by\x20other\x20packages.

\x0a

Once\x20go\x20mod\x20tidy\x20has\x20loaded\x20this\x20set\x20of\x20packages,\x20it\x20ensures\x20that\x20each\x20module\x0athat\x20provides\x20one\x20or\x20more\x20packages\x20either\x20has\x20a\x20require\x20directive\x20in\x20the\x20main\x0amodule's\x20go.mod\x20file\x20or\x20is\x20required\x20by\x20another\x20required\x20module.\x20\x20go\x20mod\x20tidy\x0awill\x20add\x20a\x20requirement\x20on\x20the\x20latest\x20version\x20on\x20each\x20missing\x20module\x20(see\x0aVersion\x20queries\x20for\x20the\x20definition\x20of\x20the\x20latest\x0aversion).\x20go\x20mod\x20tidy\x20will\x20remove\x20require\x20directives\x20for\x20modules\x20that\x20don't\x0aprovide\x20any\x20packages\x20in\x20the\x20set\x20described\x20above.

\x0a

go\x20mod\x20tidy\x20may\x20also\x20add\x20or\x20remove\x20//\x20indirect\x20comments\x20on\x20require\x0adirectives.\x20An\x20//\x20indirect\x20comment\x20denotes\x20a\x20module\x20that\x20does\x20not\x20provide\x0apackages\x20imported\x20by\x20packages\x20in\x20the\x20main\x20module.\x20These\x20requirements\x20will\x20be\x0apresent\x20if\x20the\x20module\x20that\x20imports\x20packages\x20in\x20the\x20indirect\x20dependency\x20has\x0ano\x20go.mod\x20file.\x20They\x20may\x20also\x20be\x20present\x20if\x20the\x20indirect\x20dependency\x20is\x0arequired\x20at\x20a\x20higher\x20version\x20than\x20is\x20implied\x20by\x20the\x20module\x20graph;\x20this\x20usually\x0ahappens\x20after\x20running\x20a\x20command\x20like\x20go\x20get\x20-u\x20./....

\x0ago\x20mod\x20vendor\x0a

Usage:

\x0a
go\x20mod\x20vendor\x20[-v]\x0a
\x0a

The\x20go\x20mod\x20vendor\x20command\x20constructs\x20a\x20directory\x20named\x20vendor\x20in\x20the\x20main\x0amodule's\x20root\x20directory\x20that\x20contains\x20copies\x20of\x20all\x20packages\x0aneeded\x20to\x20support\x20builds\x20and\x20tests\x20of\x20packages\x20in\x20the\x20main\x20module.\x20Packages\x0athat\x20are\x20only\x20imported\x20by\x20tests\x20of\x20packages\x20outside\x20the\x20main\x20module\x20are\x20not\x0aincluded.\x20As\x20with\x20go\x20mod\x20tidy\x20and\x20other\x20module\x20commands,\x0abuild\x20constraints\x20except\x20for\x20ignore\x20are\x20not\x0aconsidered\x20when\x20constructing\x20the\x20vendor\x20directory.

\x0a

When\x20vendoring\x20is\x20enabled,\x20the\x20go\x20command\x20will\x20load\x20packages\x20from\x20the\x20vendor\x0adirectory\x20instead\x20of\x20downloading\x20modules\x20from\x20their\x20sources\x20into\x20the\x20module\x0acache\x20and\x20using\x20packages\x20those\x20downloaded\x20copies.\x20See\x20Vendoring\x0afor\x20more\x20information.

\x0a

go\x20mod\x20vendor\x20also\x20creates\x20the\x20file\x20vendor/modules.txt\x20that\x20contains\x20a\x20list\x0aof\x20vendored\x20packages\x20and\x20the\x20module\x20versions\x20they\x20were\x20copied\x20from.\x20When\x0avendoring\x20is\x20enabled,\x20this\x20manifest\x20is\x20used\x20as\x20a\x20source\x20of\x20module\x20version\x0ainformation,\x20as\x20reported\x20by\x20go\x20list\x20-m\x20and\x20go\x20version\x20-m.\x20When\x20the\x20go\x20command\x20reads\x20vendor/modules.txt,\x20it\x20checks\x0athat\x20the\x20module\x20versions\x20are\x20consistent\x20with\x20go.mod.\x20If\x20go.mod\x20changed\x20since\x0avendor/modules.txt\x20was\x20generated,\x20go\x20mod\x20vendor\x20should\x20be\x20run\x20again.

\x0a

Note\x20that\x20go\x20mod\x20vendor\x20removes\x20the\x20vendor\x20directory\x20if\x20it\x20exists\x20before\x0are-constructing\x20it.\x20Local\x20changes\x20should\x20not\x20be\x20made\x20to\x20vendored\x20packages.\x0aThe\x20go\x20command\x20does\x20not\x20check\x20that\x20packages\x20in\x20the\x20vendor\x20directory\x20have\x0anot\x20been\x20modified,\x20but\x20one\x20can\x20verify\x20the\x20integrity\x20of\x20the\x20vendor\x20directory\x0aby\x20running\x20go\x20mod\x20vendor\x20and\x20checking\x20that\x20no\x20changes\x20were\x20made.

\x0a

The\x20-v\x20flag\x20causes\x20go\x20mod\x20vendor\x20to\x20print\x20the\x20names\x20of\x20vendored\x20modules\x0aand\x20packages\x20to\x20standard\x20error.

\x0ago\x20mod\x20verify\x0a

Usage:

\x0a
go\x20mod\x20verify\x0a
\x0a

go\x20mod\x20verify\x20checks\x20that\x20dependencies\x20of\x20the\x20main\x20module\x0astored\x20in\x20the\x20module\x20cache\x20have\x20not\x20been\x20modified\x20since\x0athey\x20were\x20downloaded.\x20To\x20perform\x20this\x20check,\x20go\x20mod\x20verify\x20hashes\x20each\x0adownloaded\x20module\x20.zip\x20file\x20and\x20extracted\x20directory,\x20then\x0acompares\x20those\x20hashes\x20with\x20a\x20hash\x20recorded\x20when\x20the\x20module\x20was\x20first\x0adownloaded.\x20go\x20mod\x20verify\x20checks\x20each\x20module\x20in\x20the\x20build\x0alist\x20(which\x20may\x20be\x20printed\x20with\x20go\x20list\x20-m\x20all).

\x0a

If\x20all\x20the\x20modules\x20are\x20unmodified,\x20go\x20mod\x20verify\x20prints\x20"all\x20modules\x0averified".\x20Otherwise,\x20it\x20reports\x20which\x20modules\x20have\x20been\x20changed\x20and\x20exits\x20with\x0aa\x20non-zero\x20status.

\x0a

Note\x20that\x20all\x20module-aware\x20commands\x20verify\x20that\x20hashes\x20in\x20the\x20main\x20module's\x0ago.sum\x20file\x20match\x20hashes\x20recorded\x20for\x20modules\x20downloaded\x20into\x20the\x20module\x0acache.\x20If\x20a\x20hash\x20is\x20missing\x20from\x20go.sum\x20(for\x20example,\x20because\x20the\x20module\x20is\x0abeing\x20used\x20for\x20the\x20first\x20time),\x20the\x20go\x20command\x20verifies\x20its\x20hash\x20using\x20the\x0achecksum\x20database\x20(unless\x20the\x20module\x20path\x20is\x20matched\x20by\x0aGOPRIVATE\x20or\x20GONOSUMDB).\x20See\x20Authenticating\x20modules\x20for\x0adetails.

\x0a

In\x20contrast,\x20go\x20mod\x20verify\x20checks\x20that\x20module\x20.zip\x20files\x20and\x20their\x20extracted\x0adirectories\x20have\x20hashes\x20that\x20match\x20hashes\x20recorded\x20in\x20the\x20module\x20cache\x20when\x20they\x0awere\x20first\x20downloaded.\x20This\x20is\x20useful\x20for\x20detecting\x20changes\x20to\x20files\x20in\x20the\x0amodule\x20cache\x20after\x20a\x20module\x20has\x20been\x20downloaded\x20and\x20verified.\x20go\x20mod\x20verify\x0adoes\x20not\x20download\x20content\x20for\x20modules\x20not\x20in\x20the\x20cache,\x20and\x20it\x20does\x20not\x20use\x0ago.sum\x20files\x20to\x20verify\x20module\x20content.\x20However,\x20go\x20mod\x20verify\x20may\x20download\x0ago.mod\x20files\x20in\x20order\x20to\x20perform\x20minimal\x20version\x0aselection.\x20It\x20will\x20use\x20go.sum\x20to\x20verify\x20those\x0afiles,\x20and\x20it\x20may\x20add\x20go.sum\x20entries\x20for\x20missing\x20hashes.

\x0ago\x20version\x20-m\x0a

Usage:

\x0a
go\x20version\x20[-m]\x20[-v]\x20[file\x20...]\x0a
\x0a

Example:

\x0a
#\x20Print\x20Go\x20version\x20used\x20to\x20build\x20go.\x0a$\x20go\x20version\x0a\x0a#\x20Print\x20Go\x20version\x20used\x20to\x20build\x20a\x20specific\x20executable.\x0a$\x20go\x20version\x20~/go/bin/gopls\x0a\x0a#\x20Print\x20Go\x20version\x20and\x20module\x20versions\x20used\x20to\x20build\x20a\x20specific\x20executable.\x0a$\x20go\x20version\x20-m\x20~/go/bin/gopls\x0a\x0a#\x20Print\x20Go\x20version\x20and\x20module\x20versions\x20used\x20to\x20build\x20executables\x20in\x20a\x20directory.\x0a$\x20go\x20version\x20-m\x20~/go/bin/\x0a
\x0a

go\x20version\x20reports\x20the\x20Go\x20version\x20used\x20to\x20build\x20each\x20executable\x20file\x20named\x0aon\x20the\x20command\x20line.

\x0a

If\x20no\x20files\x20are\x20named\x20on\x20the\x20command\x20line,\x20go\x20version\x20prints\x20its\x20own\x20version\x0ainformation.

\x0a

If\x20a\x20directory\x20is\x20named,\x20go\x20version\x20walks\x20that\x20directory,\x20recursively,\x20looking\x0afor\x20recognized\x20Go\x20binaries\x20and\x20reporting\x20their\x20versions.\x20By\x20default,\x20go\x20version\x20does\x20not\x20report\x20unrecognized\x20files\x20found\x20during\x20a\x20directory\x20scan.\x20The\x0a-v\x20flag\x20causes\x20it\x20to\x20report\x20unrecognized\x20files.

\x0a

The\x20-m\x20flag\x20causes\x20go\x20version\x20to\x20print\x20each\x20executable's\x20embedded\x20module\x0aversion\x20information,\x20when\x20available.\x20For\x20each\x20executable,\x20go\x20version\x20-m\x20prints\x0aa\x20table\x20with\x20tab-separated\x20columns\x20like\x20the\x20one\x20below.

\x0a
$\x20go\x20version\x20-m\x20~/go/bin/goimports\x0a/home/jrgopher/go/bin/goimports:\x20go1.14.3\x0a\x20\x20\x20\x20\x20\x20\x20\x20path\x20\x20\x20\x20golang.org/x/tools/cmd/goimports\x0a\x20\x20\x20\x20\x20\x20\x20\x20mod\x20\x20\x20\x20\x20golang.org/x/tools\x20\x20\x20\x20\x20\x20v0.0.0-20200518203908-8018eb2c26ba\x20\x20\x20\x20\x20\x20h1:0Lcy64USfQQL6GAJma8BdHCgeofcchQj+Z7j0SXYAzU=\x0a\x20\x20\x20\x20\x20\x20\x20\x20dep\x20\x20\x20\x20\x20golang.org/x/mod\x20\x20\x20\x20\x20\x20\x20\x20v0.2.0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=\x0a\x20\x20\x20\x20\x20\x20\x20\x20dep\x20\x20\x20\x20\x20golang.org/x/xerrors\x20\x20\x20\x20v0.0.0-20191204190536-9bdfabe68543\x20\x20\x20\x20\x20\x20h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=\x0a
\x0a

The\x20format\x20of\x20the\x20table\x20may\x20change\x20in\x20the\x20future.\x20The\x20same\x20information\x20may\x20be\x0aobtained\x20from\x0aruntime/debug.ReadBuildInfo.

\x0a

The\x20meaning\x20of\x20each\x20row\x20in\x20the\x20table\x20is\x20determined\x20by\x20the\x20word\x20in\x20the\x20first\x0acolumn.

\x0a
    \x0a
  • path:\x20the\x20path\x20of\x20the\x20main\x20package\x20used\x20to\x20build\x20the\x20executable.
  • \x0a
  • mod:\x20the\x20module\x20containing\x20the\x20main\x20package.\x20The\x20columns\x20are\x20the\x0amodule\x20path,\x20version,\x20and\x20sum,\x20respectively.\x20The\x20main\x0amodule\x20has\x20the\x20version\x20(devel)\x20and\x20no\x20sum.
  • \x0a
  • dep:\x20a\x20module\x20that\x20provided\x20one\x20or\x20more\x20packages\x20linked\x20into\x20the\x0aexecutable.\x20Same\x20format\x20as\x20mod.
  • \x0a
  • =>:\x20a\x20replacement\x20for\x20the\x20module\x20on\x20the\x20previous\x0aline.\x20If\x20the\x20replacement\x20is\x20a\x20local\x20directory,\x20only\x20the\x20directory\x20path\x20is\x0alisted\x20(no\x20version\x20or\x20sum).\x20If\x20the\x20replacement\x20is\x20a\x20module\x20version,\x20the\x20path,\x0aversion,\x20and\x20sum\x20are\x20listed,\x20as\x20with\x20mod\x20and\x20dep.\x20A\x20replaced\x20module\x20has\x0ano\x20sum.
  • \x0a
\x0ago\x20clean\x20-modcache\x0a

Usage:

\x0a
go\x20clean\x20[-modcache]\x0a
\x0a

The\x20-modcache\x20flag\x20causes\x20go\x20clean\x20to\x20remove\x20the\x20entire\x0amodule\x20cache,\x20including\x20unpacked\x20source\x20code\x20of\x20versioned\x0adependencies.

\x0a

This\x20is\x20usually\x20the\x20best\x20way\x20to\x20remove\x20the\x20module\x20cache.\x20By\x20default,\x20most\x20files\x0aand\x20directories\x20in\x20the\x20module\x20cache\x20are\x20read-only\x20to\x20prevent\x20tests\x20and\x20editors\x0afrom\x20unintentionally\x20changing\x20files\x20after\x20they've\x20been\x0aauthenticated.\x20Unfortunately,\x20this\x20causes\x20commands\x20like\x0arm\x20-r\x20to\x20fail,\x20since\x20files\x20can't\x20be\x20removed\x20without\x20first\x20making\x20their\x20parent\x0adirectories\x20writable.

\x0a

The\x20-modcacherw\x20flag\x20(accepted\x20by\x20go\x20build\x20and\x0aother\x20module-aware\x20commands)\x20causes\x20new\x20directories\x20in\x20the\x20module\x20cache\x20to\x0abe\x20writable.\x20To\x20pass\x20-modcacherw\x20to\x20all\x20module-aware\x20commands,\x20add\x20it\x20to\x20the\x0aGOFLAGS\x20variable.\x20GOFLAGS\x20may\x20be\x20set\x20in\x20the\x20environment\x20or\x20with\x20go\x20env\x20-w.\x20For\x0aexample,\x20the\x20command\x20below\x20sets\x20it\x20permanently:

\x0a
go\x20env\x20-w\x20GOFLAGS=-modcacherw\x0a
\x0a

-modcacherw\x20should\x20be\x20used\x20with\x20caution;\x20developers\x20should\x20be\x20careful\x20not\x0ato\x20make\x20changes\x20to\x20files\x20in\x20the\x20module\x20cache.\x20go\x20mod\x20verify\x0amay\x20be\x20used\x20to\x20check\x20that\x20files\x20in\x20the\x20cache\x20match\x20hashes\x20in\x20the\x20main\x20module's\x0ago.sum\x20file.

\x0aVersion\x20queries\x0a

Several\x20commands\x20allow\x20you\x20to\x20specify\x20a\x20version\x20of\x20a\x20module\x20using\x20a\x20version\x0aquery,\x20which\x20appears\x20after\x20an\x20@\x20character\x20following\x20a\x20module\x20or\x20package\x20path\x0aon\x20the\x20command\x20line.

\x0a

Examples:

\x0a
go\x20get\x20example.com/m@latest\x0ago\x20mod\x20download\x20example.com/m@master\x0ago\x20list\x20-m\x20-json\x20example.com/m@e3702bed2\x0a
\x0a

A\x20version\x20query\x20may\x20be\x20one\x20of\x20the\x20following:

\x0a
    \x0a
  • A\x20fully-specified\x20semantic\x20version,\x20such\x20as\x20v1.2.3,\x20which\x20selects\x20a\x0aspecific\x20version.\x20See\x20Versions\x20for\x20syntax.
  • \x0a
  • A\x20semantic\x20version\x20prefix,\x20such\x20as\x20v1\x20or\x20v1.2,\x20which\x20selects\x20the\x20highest\x0aavailable\x20version\x20with\x20that\x20prefix.
  • \x0a
  • A\x20semantic\x20version\x20comparison,\x20such\x20as\x20<v1.2.3\x20or\x20>=v1.5.6,\x20which\x20selects\x0athe\x20nearest\x20available\x20version\x20to\x20the\x20comparison\x20target\x20(the\x20lowest\x20version\x0afor\x20>\x20and\x20>=,\x20and\x20the\x20highest\x20version\x20for\x20<\x20and\x20<=).
  • \x0a
  • A\x20revision\x20identifier\x20for\x20the\x20underlying\x20source\x20repository,\x20such\x20as\x20a\x20commit\x0ahash\x20prefix,\x20revision\x20tag,\x20or\x20branch\x20name.\x20If\x20the\x20revision\x20is\x20tagged\x20with\x20a\x0asemantic\x20version,\x20this\x20query\x20selects\x20that\x20version.\x20Otherwise,\x20this\x20query\x0aselects\x20a\x20pseudo-version\x20for\x20the\x20underlying\x0acommit.\x20Note\x20that\x20branches\x20and\x20tags\x20with\x20names\x20matched\x20by\x20other\x20version\x0aqueries\x20cannot\x20be\x20selected\x20this\x20way.\x20For\x20example,\x20the\x20query\x20v2\x20selects\x20the\x0alatest\x20version\x20starting\x20with\x20v2,\x20not\x20the\x20branch\x20named\x20v2.
  • \x0a
  • The\x20string\x20latest,\x20which\x20selects\x20the\x20highest\x20available\x20release\x20version.\x20If\x0athere\x20are\x20no\x20release\x20versions,\x20latest\x20selects\x20the\x20highest\x20pre-release\x0aversion.\x20\x20If\x20there\x20no\x20tagged\x20versions,\x20latest\x20selects\x20a\x20pseudo-version\x20for\x0athe\x20commit\x20at\x20the\x20tip\x20of\x20the\x20repository's\x20default\x20branch.
  • \x0a
  • The\x20string\x20upgrade,\x20which\x20is\x20like\x20latest\x20except\x20that\x20if\x20the\x20module\x20is\x0acurrently\x20required\x20at\x20a\x20higher\x20version\x20than\x20the\x20version\x20latest\x20would\x20select\x0a(for\x20example,\x20a\x20pre-release),\x20upgrade\x20will\x20select\x20the\x20current\x20version.
  • \x0a
  • The\x20string\x20patch,\x20which\x20selects\x20the\x20latest\x20available\x20version\x20with\x20the\x20same\x0amajor\x20and\x20minor\x20version\x20numbers\x20as\x20the\x20currently\x20required\x20version.\x20If\x20no\x0aversion\x20is\x20currently\x20required,\x20patch\x20is\x20equivalent\x20to\x20latest.
  • \x0a
\x0a

Except\x20for\x20queries\x20for\x20specific\x20named\x20versions\x20or\x20revisions,\x20all\x20queries\x0aconsider\x20available\x20versions\x20reported\x20by\x20go\x20list\x20-m\x20-versions\x20(see\x20go\x20list\x20-m).\x20This\x20list\x20contains\x20only\x20tagged\x20versions,\x20not\x20pseudo-versions.\x0aModule\x20versions\x20disallowed\x20by\x20exclude\x20directives\x20in\x0athe\x20main\x20module's\x20go.mod\x20file\x20are\x20not\x20considered.

\x0a

Release\x20versions\x20are\x20preferred\x20over\x20pre-release\x0aversions.\x20For\x20example,\x20if\x20versions\x20v1.2.2\x20and\x20v1.2.3-pre\x20are\x20available,\x20the\x0alatest\x20query\x20will\x20select\x20v1.2.2,\x20even\x20though\x20v1.2.3-pre\x20is\x20higher.\x20The\x0a<v1.2.4\x20query\x20would\x20also\x20select\x20v1.2.2,\x20even\x20though\x20v1.2.3-pre\x20is\x20closer\x0ato\x20v1.2.4.\x20If\x20no\x20release\x20or\x20pre-release\x20version\x20is\x20available,\x20the\x20latest,\x0aupgrade,\x20and\x20patch\x20queries\x20will\x20select\x20a\x20pseudo-version\x20for\x20the\x20commit\x0aat\x20the\x20tip\x20of\x20the\x20repository's\x20default\x20branch.\x20Other\x20queries\x20will\x20report\x0aan\x20error.

\x0aModule\x20commands\x20outside\x20a\x20module\x0a

Module-aware\x20Go\x20commands\x20normally\x20run\x20in\x20the\x20context\x20of\x20a\x20main\x0amodule\x20defined\x20by\x20a\x20go.mod\x20file\x20in\x20the\x20working\x20directory\x0aor\x20a\x20parent\x20directory.\x20Some\x20commands\x20may\x20be\x20run\x20in\x20module-aware\x20mode\x20without\x20a\x0ago.mod\x20file\x20by\x20setting\x20the\x20GO111MODULE\x20environment\x20variable\x20to\x20on.\x0aMost\x20commands\x20work\x20differently\x20when\x20no\x20go.mod\x20file\x20is\x20present.

\x0a

See\x20Module-aware\x20commands\x20for\x20information\x20on\x20enabling\x20and\x0adisabling\x20module-aware\x20mode.

\x0a\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20Command\x0a\x20\x20\x20\x20\x20\x20Behavior\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20build
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20doc
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20fix
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20fmt
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20generate
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20install
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20list
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20run
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20test
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20vet\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Only\x20packages\x20in\x20the\x20standard\x20library\x20and\x20packages\x20specified\x20as\x0a\x20\x20\x20\x20\x20\x20\x20\x20.go\x20files\x20on\x20the\x20command\x20line\x20can\x20be\x20loaded,\x20imported,\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20built.\x20Packages\x20from\x20other\x20modules\x20cannot\x20be\x20built,\x20since\x20there\x20is\x20no\x0a\x20\x20\x20\x20\x20\x20\x20\x20place\x20to\x20record\x20module\x20requirements\x20and\x20ensure\x20deterministic\x20builds.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20go\x20get\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Packages\x20and\x20executables\x20may\x20be\x20built\x20and\x20installed\x20as\x20usual.\x20Note\x20that\x0a\x20\x20\x20\x20\x20\x20\x20\x20there\x20is\x20no\x20main\x20module\x20when\x20go\x20get\x20is\x20run\x20without\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20go.mod\x20file,\x20so\x20replace\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20exclude\x20directives\x20are\x20not\x20applied.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20go\x20list\x20-m\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Explicit\x20version\x20queries\x20are\x20required\x0a\x20\x20\x20\x20\x20\x20\x20\x20for\x20most\x20arguments,\x20except\x20when\x20the\x20-versions\x20flag\x20is\x20used.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20go\x20mod\x20download\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Explicit\x20version\x20queries\x20are\x20required\x0a\x20\x20\x20\x20\x20\x20\x20\x20for\x20most\x20arguments.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20go\x20mod\x20edit\x0a\x20\x20\x20\x20\x20\x20An\x20explicit\x20file\x20argument\x20is\x20required.\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20mod\x20graph
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20mod\x20tidy
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20mod\x20vendor
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20mod\x20verify
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20mod\x20why\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20These\x20commands\x20require\x20a\x20go.mod\x20file\x20and\x20will\x20report\x0a\x20\x20\x20\x20\x20\x20\x20\x20an\x20error\x20if\x20one\x20is\x20not\x20present.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x0aModule\x20proxies\x0aGOPROXY\x20protocol\x0a

A\x20module\x20proxy\x20is\x20an\x20HTTP\x20server\x20that\x20can\x20respond\x20to\x20GET\x20requests\x0afor\x20paths\x20specified\x20below.\x20The\x20requests\x20have\x20no\x20query\x20parameters,\x20and\x20no\x0aspecific\x20headers\x20are\x20required,\x20so\x20even\x20a\x20site\x20serving\x20from\x20a\x20fixed\x20file\x20system\x0a(including\x20a\x20file://\x20URL)\x20can\x20be\x20a\x20module\x20proxy.

\x0a

Successful\x20HTTP\x20responses\x20must\x20have\x20the\x20status\x20code\x20200\x20(OK).\x20Redirects\x20(3xx)\x0aare\x20followed.\x20Responses\x20with\x20status\x20codes\x204xx\x20and\x205xx\x20are\x20treated\x20as\x20errors.\x0aThe\x20error\x20codes\x20404\x20(Not\x20Found)\x20and\x20410\x20(Gone)\x20indicate\x20that\x20the\x0arequested\x20module\x20or\x20version\x20is\x20not\x20available\x20on\x20the\x20proxy,\x20but\x20it\x20may\x20be\x20found\x0aelsewhere.\x20Error\x20responses\x20should\x20have\x20content\x20type\x20text/plain\x20with\x0acharset\x20either\x20utf-8\x20or\x20us-ascii.

\x0a

The\x20go\x20command\x20may\x20be\x20configured\x20to\x20contact\x20proxies\x20or\x20source\x20control\x20servers\x0ausing\x20the\x20GOPROXY\x20environment\x20variable,\x20which\x20accepts\x20a\x20list\x20of\x20proxy\x20URLs.\x0aThe\x20list\x20may\x20include\x20the\x20keywords\x20direct\x20or\x20off\x20(see\x20Environment\x0avariables\x20for\x20details).\x20List\x20elements\x20may\x20be\x20separated\x0aby\x20commas\x20(,)\x20or\x20pipes\x20(|),\x20which\x20determine\x20error\x20fallback\x20behavior.\x20When\x20a\x0aURL\x20is\x20followed\x20by\x20a\x20comma,\x20the\x20go\x20command\x20falls\x20back\x20to\x20later\x20sources\x20only\x0aafter\x20a\x20404\x20(Not\x20Found)\x20or\x20410\x20(Gone)\x20response.\x20When\x20a\x20URL\x20is\x20followed\x20by\x20a\x0apipe,\x20the\x20go\x20command\x20falls\x20back\x20to\x20later\x20sources\x20after\x20any\x20error,\x20including\x0anon-HTTP\x20errors\x20such\x20as\x20timeouts.\x20This\x20error\x20handling\x20behavior\x20lets\x20a\x20proxy\x20act\x0aas\x20a\x20gatekeeper\x20for\x20unknown\x20modules.\x20For\x20example,\x20a\x20proxy\x20could\x20respond\x20with\x0aerror\x20403\x20(Forbidden)\x20for\x20modules\x20not\x20on\x20an\x20approved\x20list\x20(see\x20Private\x20proxy\x0aserving\x20private\x20modules).

\x0a

The\x20table\x20below\x20specifies\x20queries\x20that\x20a\x20module\x20proxy\x20must\x20respond\x20to.\x20For\x20each\x0apath,\x20$base\x20is\x20the\x20path\x20portion\x20of\x20a\x20proxy\x20URL,$module\x20is\x20a\x20module\x20path,\x20and\x0a$version\x20is\x20a\x20version.\x20For\x20example,\x20if\x20the\x20proxy\x20URL\x20is\x0ahttps://example.com/mod,\x20and\x20the\x20client\x20is\x20requesting\x20the\x20go.mod\x20file\x20for\x0athe\x20module\x20golang.org/x/text\x20at\x20version\x20v0.3.2,\x20the\x20client\x20would\x20send\x20a\x0aGET\x20request\x20for\x20https://example.com/mod/golang.org/x/text/@v/v0.3.2.mod.

\x0a

To\x20avoid\x20ambiguity\x20when\x20serving\x20from\x20case-insensitive\x20file\x20systems,\x0athe\x20$module\x20and\x20$version\x20elements\x20are\x20case-encoded\x20by\x20replacing\x20every\x0auppercase\x20letter\x20with\x20an\x20exclamation\x20mark\x20followed\x20by\x20the\x20corresponding\x0alower-case\x20letter.\x20This\x20allows\x20modules\x20example.com/M\x20and\x20example.com/m\x20to\x0aboth\x20be\x20stored\x20on\x20disk,\x20since\x20the\x20former\x20is\x20encoded\x20as\x20example.com/!m.

\x0a\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20Path\x0a\x20\x20\x20\x20\x20\x20Description\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$base/$module/@v/list\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Returns\x20a\x20list\x20of\x20known\x20versions\x20of\x20the\x20given\x20module\x20in\x20plain\x20text,\x20one\x0a\x20\x20\x20\x20\x20\x20\x20\x20per\x20line.\x20This\x20list\x20should\x20not\x20include\x20pseudo-versions.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$base/$module/@v/$version.info\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Returns\x20JSON-formatted\x20metadata\x20about\x20a\x20specific\x20version\x20of\x20a\x20module.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20The\x20response\x20must\x20be\x20a\x20JSON\x20object\x20that\x20corresponds\x20to\x20the\x20Go\x20data\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20structure\x20below:\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20
\x0atype\x20Info\x20struct\x20{\x0a\x20\x20\x20\x20Version\x20string\x20\x20\x20\x20//\x20version\x20string\x0a\x20\x20\x20\x20Time\x20\x20\x20\x20time.Time\x20//\x20commit\x20time\x0a}\x0a
\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20The\x20Version\x20field\x20is\x20required\x20and\x20must\x20contain\x20a\x20valid,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20canonical\x20version\x20(see\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Versions).\x20The\x20$version\x20in\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20request\x20path\x20does\x20not\x20need\x20to\x20be\x20the\x20same\x20version\x20or\x20even\x20a\x20valid\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20version;\x20this\x20endpoint\x20may\x20be\x20used\x20to\x20find\x20versions\x20for\x20branch\x20names\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20or\x20revision\x20identifiers.\x20However,\x20if\x20$version\x20is\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20canonical\x20version\x20with\x20a\x20major\x20version\x20compatible\x20with\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20$module,\x20the\x20Version\x20field\x20in\x20a\x20successful\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20response\x20must\x20be\x20the\x20same.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20The\x20Time\x20field\x20is\x20optional.\x20If\x20present,\x20it\x20must\x20be\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20string\x20in\x20RFC\x203339\x20format.\x20It\x20indicates\x20the\x20time\x20when\x20the\x20version\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20was\x20created.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20More\x20fields\x20may\x20be\x20added\x20in\x20the\x20future,\x20so\x20other\x20names\x20are\x20reserved.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$base/$module/@v/$version.mod\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Returns\x20the\x20go.mod\x20file\x20for\x20a\x20specific\x20version\x20of\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20module.\x20If\x20the\x20module\x20does\x20not\x20have\x20a\x20go.mod\x20file\x20at\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20requested\x20version,\x20a\x20file\x20containing\x20only\x20a\x20module\x0a\x20\x20\x20\x20\x20\x20\x20\x20statement\x20with\x20the\x20requested\x20module\x20path\x20must\x20be\x20returned.\x20Otherwise,\x0a\x20\x20\x20\x20\x20\x20\x20\x20the\x20original,\x20unmodified\x20go.mod\x20file\x20must\x20be\x20returned.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$base/$module/@v/$version.zip\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Returns\x20a\x20zip\x20file\x20containing\x20the\x20contents\x20of\x20a\x20specific\x20version\x20of\x0a\x20\x20\x20\x20\x20\x20\x20\x20a\x20module.\x20See\x20Module\x20zip\x20files\x20for\x20details\x0a\x20\x20\x20\x20\x20\x20\x20\x20on\x20how\x20this\x20zip\x20file\x20must\x20be\x20formatted.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$base/$module/@latest\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Returns\x20JSON-formatted\x20metadata\x20about\x20the\x20latest\x20known\x20version\x20of\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20module\x20in\x20the\x20same\x20format\x20as\x0a\x20\x20\x20\x20\x20\x20\x20\x20$base/$module/@v/$version.info.\x20The\x20latest\x20version\x20should\x0a\x20\x20\x20\x20\x20\x20\x20\x20be\x20the\x20version\x20of\x20the\x20module\x20that\x20the\x20go\x20command\x20should\x20use\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20$base/$module/@v/list\x20is\x20empty\x20or\x20no\x20listed\x20version\x20is\x0a\x20\x20\x20\x20\x20\x20\x20\x20suitable.\x20This\x20endpoint\x20is\x20optional,\x20and\x20module\x20proxies\x20are\x20not\x20required\x0a\x20\x20\x20\x20\x20\x20\x20\x20to\x20implement\x20it.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x0a

When\x20resolving\x20the\x20latest\x20version\x20of\x20a\x20module,\x20the\x20go\x20command\x20will\x20request\x0a$base/$module/@v/list,\x20then,\x20if\x20no\x20suitable\x20versions\x20are\x20found,\x0a$base/$module/@latest.\x20The\x20go\x20command\x20prefers,\x20in\x20order:\x20the\x20semantically\x0ahighest\x20release\x20version,\x20the\x20semantically\x20highest\x20pre-release\x20version,\x20and\x20the\x0achronologically\x20most\x20recent\x20pseudo-version.\x20In\x20Go\x201.12\x20and\x20earlier,\x20the\x20go\x0acommand\x20considered\x20pseudo-versions\x20in\x20$base/$module/@v/list\x20to\x20be\x20pre-release\x0aversions,\x20but\x20this\x20is\x20no\x20longer\x20true\x20since\x20Go\x201.13.

\x0a

A\x20module\x20proxy\x20must\x20always\x20serve\x20the\x20same\x20content\x20for\x20successful\x0aresponses\x20for\x20$base/$module/$version.mod\x20and\x20$base/$module/$version.zip\x0aqueries.\x20This\x20content\x20is\x20cryptographically\x20authenticated\x0ausing\x20go.sum\x20files\x20and,\x20by\x20default,\x20the\x0achecksum\x20database.

\x0a

The\x20go\x20command\x20caches\x20most\x20content\x20it\x20downloads\x20from\x20module\x20proxies\x20in\x20its\x0amodule\x20cache\x20in\x20$GOPATH/pkg/mod/cache/download.\x20Even\x20when\x20downloading\x20directly\x0afrom\x20version\x20control\x20systems,\x20the\x20go\x20command\x20synthesizes\x20explicit\x20info,\x0amod,\x20and\x20zip\x20files\x20and\x20stores\x20them\x20in\x20this\x20directory,\x20the\x20same\x20as\x20if\x20it\x20had\x0adownloaded\x20them\x20directly\x20from\x20a\x20proxy.\x20The\x20cache\x20layout\x20is\x20the\x20same\x20as\x20the\x20proxy\x0aURL\x20space,\x20so\x20serving\x20$GOPATH/pkg/mod/cache/download\x20at\x20(or\x20copying\x20it\x20to)\x0ahttps://example.com/proxy\x20would\x20let\x20users\x20access\x20cached\x20module\x20versions\x20by\x0asetting\x20GOPROXY\x20to\x20https://example.com/proxy.

\x0aCommunicating\x20with\x20proxies\x0a

The\x20go\x20command\x20may\x20download\x20module\x20source\x20code\x20and\x20metadata\x20from\x20a\x20module\x0aproxy.\x20The\x20GOPROXY\x20environment\x0avariable\x20may\x20be\x20used\x20to\x20configure\x20which\x20proxies\x20the\x0ago\x20command\x20may\x20connect\x20to\x20and\x20whether\x20it\x20may\x20communicate\x20directly\x20with\x0aversion\x20control\x20systems.\x20Downloaded\x20module\x20data\x20is\x20saved\x20in\x20the\x20module\x0acache.\x20The\x20go\x20command\x20will\x20only\x20contact\x20a\x20proxy\x20when\x20it\x0aneeds\x20information\x20not\x20already\x20in\x20the\x20cache.

\x0a

The\x20GOPROXY\x20protocol\x20section\x20describes\x20requests\x20that\x0amay\x20be\x20sent\x20to\x20a\x20GOPROXY\x20server.\x20However,\x20it's\x20also\x20helpful\x20to\x20understand\x0awhen\x20the\x20go\x20command\x20makes\x20these\x20requests.\x20For\x20example,\x20go\x20build\x20follows\x0athe\x20procedure\x20below:

\x0a
    \x0a
  • Compute\x20the\x20build\x20list\x20by\x20reading\x20go.mod\x0afiles\x20and\x20performing\x20minimal\x20version\x20selection\x0a(MVS).
  • \x0a
  • Read\x20the\x20packages\x20named\x20on\x20the\x20command\x20line\x20and\x20the\x20packages\x20they\x20import.
  • \x0a
  • If\x20a\x20package\x20is\x20not\x20provided\x20by\x20any\x20module\x20in\x20the\x20build\x20list,\x20find\x20a\x20module\x0athat\x20provides\x20it.\x20Add\x20a\x20module\x20requirement\x20on\x20its\x20latest\x20version\x20to\x20go.mod,\x0aand\x20start\x20over.
  • \x0a
  • Build\x20packages\x20after\x20everything\x20is\x20loaded.
  • \x0a
\x0a

When\x20the\x20go\x20command\x20computes\x20the\x20build\x20list,\x20it\x20loads\x20the\x20go.mod\x20file\x20for\x0aeach\x20module\x20in\x20the\x20module\x20graph.\x20If\x20a\x20go.mod\x20file\x20is\x20not\x0ain\x20the\x20cache,\x20the\x20go\x20command\x20will\x20download\x20it\x20from\x20the\x20proxy\x20using\x20a\x0a$module/@v/$version.mod\x20request\x20(where\x20$module\x20is\x20the\x20module\x20path\x20and\x0a$version\x20is\x20the\x20version).\x20These\x20requests\x20can\x20be\x20tested\x20with\x20a\x20tool\x20like\x0acurl.\x20For\x20example,\x20the\x20command\x20below\x20downloads\x20the\x20go.mod\x20file\x20for\x0agolang.org/x/mod\x20at\x20version\x20v0.2.0:

\x0a
$\x20curl\x20https://proxy.golang.org/golang.org/x/mod/@v/v0.2.0.mod\x0amodule\x20golang.org/x/mod\x0a\x0ago\x201.12\x0a\x0arequire\x20(\x0a\x09golang.org/x/crypto\x20v0.0.0-20191011191535-87dc89f01550\x0a\x09golang.org/x/tools\x20v0.0.0-20191119224855-298f0cb1881e\x0a\x09golang.org/x/xerrors\x20v0.0.0-20191011141410-1b5146add898\x0a)\x0a
\x0a

In\x20order\x20to\x20load\x20a\x20package,\x20the\x20go\x20command\x20needs\x20the\x20source\x20code\x20for\x20the\x0amodule\x20that\x20provides\x20it.\x20Module\x20source\x20code\x20is\x20distributed\x20in\x20.zip\x20files\x20which\x0aare\x20extracted\x20into\x20the\x20module\x20cache.\x20If\x20a\x20module\x20.zip\x20is\x20not\x20in\x20the\x20cache,\x0athe\x20go\x20command\x20will\x20download\x20it\x20using\x20a\x20$module/@v/$version.zip\x20request.

\x0a
$\x20curl\x20-O\x20https://proxy.golang.org/golang.org/x/mod/@v/v0.2.0.zip\x0a$\x20unzip\x20-l\x20v0.2.0.zip\x20|\x20head\x0aArchive:\x20\x20v0.2.0.zip\x0a\x20\x20Length\x20\x20\x20\x20\x20\x20Date\x20\x20\x20\x20Time\x20\x20\x20\x20Name\x0a---------\x20\x20----------\x20-----\x20\x20\x20----\x0a\x20\x20\x20\x20\x201479\x20\x2000-00-1980\x2000:00\x20\x20\x20golang.org/x/mod@v0.2.0/LICENSE\x0a\x20\x20\x20\x20\x201303\x20\x2000-00-1980\x2000:00\x20\x20\x20golang.org/x/mod@v0.2.0/PATENTS\x0a\x20\x20\x20\x20\x20\x20559\x20\x2000-00-1980\x2000:00\x20\x20\x20golang.org/x/mod@v0.2.0/README\x0a\x20\x20\x20\x20\x20\x20\x2021\x20\x2000-00-1980\x2000:00\x20\x20\x20golang.org/x/mod@v0.2.0/codereview.cfg\x0a\x20\x20\x20\x20\x20\x20214\x20\x2000-00-1980\x2000:00\x20\x20\x20golang.org/x/mod@v0.2.0/go.mod\x0a\x20\x20\x20\x20\x201476\x20\x2000-00-1980\x2000:00\x20\x20\x20golang.org/x/mod@v0.2.0/go.sum\x0a\x20\x20\x20\x20\x205224\x20\x2000-00-1980\x2000:00\x20\x20\x20golang.org/x/mod@v0.2.0/gosumcheck/main.go\x0a
\x0a

Note\x20that\x20.mod\x20and\x20.zip\x20requests\x20are\x20separate,\x20even\x20though\x20go.mod\x20files\x0aare\x20usually\x20contained\x20within\x20.zip\x20files.\x20The\x20go\x20command\x20may\x20need\x20to\x20download\x0ago.mod\x20files\x20for\x20many\x20different\x20modules,\x20and\x20.mod\x20files\x20are\x20much\x20smaller\x0athan\x20.zip\x20files.\x20Additionally,\x20if\x20a\x20Go\x20project\x20does\x20not\x20have\x20a\x20go.mod\x20file,\x0athe\x20proxy\x20will\x20serve\x20a\x20synthetic\x20go.mod\x20file\x20that\x20only\x20contains\x20a\x20module\x0adirective.\x20Synthetic\x20go.mod\x20files\x20are\x20generated\x20by\x20the\x20go\x0acommand\x20when\x20downloading\x20from\x20a\x20version\x20control\x0asystem.

\x0a

If\x20the\x20go\x20command\x20needs\x20to\x20load\x20a\x20package\x20not\x20provided\x20by\x20any\x20module\x20in\x20the\x0abuild\x20list,\x20it\x20will\x20attempt\x20to\x20find\x20a\x20new\x20module\x20that\x20provides\x20it.\x20The\x20section\x0aResolving\x20a\x20package\x20to\x20a\x20module\x20describes\x20this\x20process.\x20In\x0asummary,\x20the\x20go\x20command\x20requests\x20information\x20about\x20the\x20latest\x20version\x20of\x20each\x0amodule\x20path\x20that\x20could\x20possibly\x20contain\x20the\x20package.\x20For\x20example,\x20for\x20the\x0apackage\x20golang.org/x/net/html,\x20the\x20go\x20command\x20would\x20try\x20to\x20find\x20the\x20latest\x0aversions\x20of\x20the\x20modules\x20golang.org/x/net/html,\x20golang.org/x/net,\x0agolang.org/x/,\x20and\x20golang.org.\x20Only\x20golang.org/x/net\x20actually\x20exists\x20and\x0aprovides\x20that\x20package,\x20so\x20the\x20go\x20command\x20uses\x20the\x20latest\x20version\x20of\x20that\x0amodule.\x20If\x20more\x20than\x20one\x20module\x20provides\x20the\x20package,\x20the\x20go\x20command\x20will\x20use\x0athe\x20module\x20with\x20the\x20longest\x20path.

\x0a

When\x20the\x20go\x20command\x20requests\x20the\x20latest\x20version\x20of\x20a\x20module,\x20it\x20first\x20sends\x20a\x0arequest\x20for\x20$module/@v/list.\x20If\x20the\x20list\x20is\x20empty\x20or\x20none\x20of\x20the\x20returned\x0aversions\x20can\x20be\x20used,\x20it\x20sends\x20a\x20request\x20for\x20$module/@latest.\x20Once\x20a\x20version\x0ais\x20chosen,\x20the\x20go\x20command\x20sends\x20a\x20$module/@v/$version.info\x20request\x20for\x0ametadata.\x20It\x20may\x20then\x20send\x20$module/@v/$version.mod\x20and\x0a$module/@v/$version.zip\x20requests\x20to\x20load\x20the\x20go.mod\x20file\x20and\x20source\x20code.

\x0a
$\x20curl\x20https://proxy.golang.org/golang.org/x/mod/@v/list\x0av0.1.0\x0av0.2.0\x0a\x0a$\x20curl\x20https://proxy.golang.org/golang.org/x/mod/@v/v0.2.0.info\x0a{"Version":"v0.2.0","Time":"2020-01-02T17:33:45Z"}\x0a
\x0a

After\x20downloading\x20a\x20.mod\x20or\x20.zip\x20file,\x20the\x20go\x20command\x20computes\x20a\x0acryptographic\x20hash\x20and\x20checks\x20that\x20it\x20matches\x20a\x20hash\x20in\x20the\x20main\x20module's\x0ago.sum\x20file.\x20If\x20the\x20hash\x20is\x20not\x20present\x20in\x20go.sum,\x20by\x20default,\x20the\x20go\x0acommand\x20retrieves\x20it\x20from\x20the\x20checksum\x20database.\x20If\x20the\x0acomputed\x20hash\x20does\x20not\x20match,\x20the\x20go\x20command\x20reports\x20a\x20security\x20error\x20and\x20does\x0anot\x20install\x20the\x20file\x20in\x20the\x20module\x20cache.\x20The\x20GOPRIVATE\x20and\x20GONOSUMDB\x0aenvironment\x20variables\x20may\x20be\x20used\x20to\x20disable\x20requests\x0ato\x20the\x20checksum\x20database\x20for\x20specific\x20modules.\x20The\x20GOSUMDB\x20environment\x0avariable\x20may\x20also\x20be\x20set\x20to\x20off\x20to\x20disable\x20requests\x20to\x20the\x20checksum\x20database\x0aentirely.\x20See\x20Authenticating\x20modules\x20for\x20more\x0ainformation.\x20Note\x20that\x20version\x20lists\x20and\x20version\x20metadata\x20returned\x20for\x20.info\x0arequests\x20are\x20not\x20authenticated\x20and\x20may\x20change\x20over\x20time.

\x0aVersion\x20control\x20systems\x0a

The\x20go\x20command\x20may\x20download\x20module\x20source\x20code\x20and\x20metadata\x20directly\x20from\x20a\x0aversion\x20control\x20repository.\x20Downloading\x20a\x20module\x20from\x20a\x0aproxy\x20is\x20usually\x20faster,\x20but\x20connecting\x20directly\x0ato\x20a\x20repository\x20is\x20necessary\x20if\x20a\x20proxy\x20is\x20not\x20available\x20or\x20if\x20a\x20module's\x0arepository\x20is\x20not\x20accessible\x20to\x20a\x20proxy\x20(frequently\x20true\x20for\x20private\x0arepositories).\x20Git,\x20Subversion,\x20Mercurial,\x20Bazaar,\x20and\x20Fossil\x20are\x20supported.\x20A\x0aversion\x20control\x20tool\x20must\x20be\x20installed\x20in\x20a\x20directory\x20in\x20PATH\x20in\x20order\x20for\x20the\x0ago\x20command\x20to\x20use\x20it.

\x0a

To\x20download\x20specific\x20modules\x20from\x20source\x20repositories\x20instead\x20of\x20a\x20proxy,\x20set\x0athe\x20GOPRIVATE\x20or\x20GONOPROXY\x20environment\x20variables.\x20To\x20configure\x20the\x20go\x0acommand\x20to\x20download\x20all\x20modules\x20directly\x20from\x20source\x20repositories,\x20set\x20GOPROXY\x0ato\x20direct.\x20See\x20Environment\x20variables\x20for\x20more\x0ainformation.

\x0aFinding\x20a\x20repository\x20for\x20a\x20module\x20path\x0a

When\x20the\x20go\x20command\x20downloads\x20a\x20module\x20in\x20direct\x20mode,\x20it\x20starts\x20by\x20locating\x0athe\x20repository\x20that\x20contains\x20the\x20module.\x20The\x20go\x20command\x20sends\x20an\x0aHTTP\x20GET\x20request\x20to\x20a\x20URL\x20derived\x20from\x20the\x20module\x20path\x20with\x20a\x0a?go-get=1\x20query\x20string.\x20For\x20example,\x20for\x20the\x20module\x20golang.org/x/mod,\x0athe\x20go\x20command\x20may\x20send\x20the\x20following\x20requests:

\x0a
https://golang.org/x/mod?go-get=1\x20(preferred)\x0ahttp://golang.org/x/mod?go-get=1\x20\x20(fallback,\x20only\x20with\x20GOINSECURE)\x0a
\x0a

The\x20go\x20command\x20will\x20follow\x20redirects\x20but\x20otherwise\x20ignores\x20response\x20status\x0acodes,\x20so\x20the\x20server\x20may\x20respond\x20with\x20a\x20404\x20or\x20any\x20other\x20error\x20status.\x20The\x0aGOINSECURE\x20environment\x20variable\x20may\x20be\x20set\x20to\x20allow\x20fallback\x20and\x20redirects\x20to\x0aunencrypted\x20HTTP\x20for\x20specific\x20modules.

\x0a

The\x20server\x20must\x20respond\x20with\x20an\x20HTML\x20document\x20containing\x20a\x20<meta>\x20tag\x20in\x20the\x0adocument's\x20<head>.\x20The\x20<meta>\x20tag\x20should\x20appear\x20early\x20in\x20the\x20document\x20to\x0aavoid\x20confusing\x20the\x20go\x20command's\x20restricted\x20parser.\x20In\x20particular,\x20it\x20should\x0aappear\x20before\x20any\x20raw\x20JavaScript\x20or\x20CSS.\x20The\x20<meta>\x20tag\x20must\x20have\x20the\x20form:

\x0a
<meta\x20name="go-import"\x20content="root-path\x20vcs\x20repo-url">\x0a
\x0a

root-path\x20is\x20the\x20repository\x20root\x20path,\x20the\x20portion\x20of\x20the\x20module\x20path\x20that\x0acorresponds\x20to\x20the\x20repository's\x20root\x20directory.\x20It\x20must\x20be\x20a\x20prefix\x20or\x20an\x20exact\x0amatch\x20of\x20the\x20requested\x20module\x20path.\x20If\x20it's\x20not\x20an\x20exact\x20match,\x20another\x20request\x0ais\x20made\x20for\x20the\x20prefix\x20to\x20verify\x20the\x20<meta>\x20tags\x20match.

\x0a

vcs\x20is\x20the\x20version\x20control\x20system.\x20It\x20must\x20be\x20one\x20of\x20bzr,\x20fossil,\x20git,\x0ahg,\x20svn,\x20mod.\x20The\x20mod\x20scheme\x20instructs\x20the\x20go\x20command\x20to\x20download\x20the\x0amodule\x20from\x20the\x20given\x20URL\x20using\x20the\x20GOPROXY\x0aprotocol.\x20This\x20allows\x20developers\x20to\x20distribute\x20modules\x0awithout\x20exposing\x20source\x20repositories.

\x0a

repo-url\x20is\x20the\x20repository's\x20URL.\x20If\x20the\x20URL\x20does\x20not\x20include\x20a\x20scheme,\x20the\x0ago\x20command\x20will\x20try\x20each\x20protocol\x20supported\x20by\x20the\x20version\x20control\x20system.\x0aFor\x20example,\x20with\x20Git,\x20the\x20go\x20command\x20will\x20try\x20https://\x20then\x20git+ssh://.\x0aInsecure\x20protocols\x20may\x20only\x20be\x20used\x20if\x20the\x20module\x20path\x20is\x20matched\x20by\x20the\x0aGOINSECURE\x20environment\x20variable.

\x0a

As\x20an\x20example,\x20consider\x20golang.org/x/mod\x20again.\x20The\x20go\x20command\x20sends\x0aa\x20request\x20to\x20https://golang.org/x/mod?go-get=1.\x20The\x20server\x20responds\x0awith\x20an\x20HTML\x20document\x20containing\x20the\x20tag:

\x0a
<meta\x20name="go-import"\x20content="golang.org/x/mod\x20git\x20https://go.googlesource.com/mod">\x0a
\x0a

From\x20this\x20response,\x20the\x20go\x20command\x20will\x20use\x20the\x20Git\x20repository\x20at\x0athe\x20remote\x20URL\x20https://go.googlesource.com/mod.

\x0a

GitHub\x20and\x20other\x20popular\x20hosting\x20services\x20respond\x20to\x20?go-get=1\x20queries\x20for\x0aall\x20repositories,\x20so\x20usually\x20no\x20server\x20configuration\x20is\x20necessary\x20for\x20modules\x0ahosted\x20at\x20those\x20sites.

\x0a

After\x20the\x20repository\x20URL\x20is\x20found,\x20the\x20go\x20command\x20will\x20clone\x20the\x20repository\x0ainto\x20the\x20module\x20cache.\x20In\x20general,\x20the\x20go\x20command\x20tries\x20to\x20avoid\x20fetching\x0aunneeded\x20data\x20from\x20a\x20repository.\x20However,\x20the\x20actual\x20commands\x20used\x20vary\x20by\x0aversion\x20control\x20system\x20and\x20may\x20change\x20over\x20time.\x20For\x20Git,\x20the\x20go\x20command\x20can\x0alist\x20most\x20available\x20versions\x20without\x20downloading\x20commits.\x20It\x20will\x20usually\x20fetch\x0acommits\x20without\x20downloading\x20ancestor\x20commits,\x20but\x20doing\x20so\x20is\x20sometimes\x0anecessary.

\x0aMapping\x20versions\x20to\x20commits\x0a

The\x20go\x20command\x20may\x20check\x20out\x20a\x20module\x20within\x20a\x20repository\x20at\x20a\x20specific\x0acanonical\x20version\x20like\x20v1.2.3,\x20v2.4.0-beta,\x20or\x0av3.0.0+incompatible.\x20Each\x20module\x20version\x20should\x20have\x20a\x20semantic\x20version\x0atag\x20within\x20the\x20repository\x20that\x20indicates\x20which\x20revision\x20should\x20be\x20checked\x0aout\x20for\x20a\x20given\x20version.

\x0a

If\x20a\x20module\x20is\x20defined\x20in\x20the\x20repository\x20root\x20directory\x20or\x20in\x20a\x20major\x20version\x0asubdirectory\x20of\x20the\x20root\x20directory,\x20then\x20each\x20version\x20tag\x20name\x20is\x20equal\x20to\x20the\x0acorresponding\x20version.\x20For\x20example,\x20the\x20module\x20golang.org/x/text\x20is\x20defined\x20in\x0athe\x20root\x20directory\x20of\x20its\x20repository,\x20so\x20the\x20version\x20v0.3.2\x20has\x20the\x20tag\x0av0.3.2\x20in\x20that\x20repository.\x20This\x20is\x20true\x20for\x20most\x20modules.

\x0a

If\x20a\x20module\x20is\x20defined\x20in\x20a\x20subdirectory\x20within\x20the\x20repository,\x20that\x20is,\x20the\x0amodule\x20subdirectory\x20portion\x20of\x20the\x20module\x20path\x20is\x0anot\x20empty,\x20then\x20each\x20tag\x20name\x20must\x20be\x20prefixed\x20with\x20the\x20module\x20subdirectory,\x0afollowed\x20by\x20a\x20slash.\x20For\x20example,\x20the\x20module\x20golang.org/x/tools/gopls\x20is\x0adefined\x20in\x20the\x20gopls\x20subdirectory\x20of\x20the\x20repository\x20with\x20root\x20path\x0agolang.org/x/tools.\x20The\x20version\x20v0.4.0\x20of\x20that\x20module\x20must\x20have\x20the\x20tag\x0anamed\x20gopls/v0.4.0\x20in\x20that\x20repository.

\x0a

The\x20major\x20version\x20number\x20of\x20a\x20semantic\x20version\x20tag\x20must\x20be\x20consistent\x20with\x20the\x0amodule\x20path's\x20major\x20version\x20suffix\x20(if\x20any).\x20For\x20example,\x20the\x20tag\x20v1.0.0\x20could\x0abelong\x20to\x20the\x20module\x20example.com/mod\x20but\x20not\x20example.com/mod/v2,\x20which\x20would\x0ahave\x20tags\x20like\x20v2.0.0.

\x0a

A\x20tag\x20with\x20major\x20version\x20v2\x20or\x20higher\x20may\x20belong\x20to\x20a\x20module\x20without\x20a\x20major\x0aversion\x20suffix\x20if\x20no\x20go.mod\x20file\x20is\x20present,\x20and\x20the\x20module\x20is\x20in\x20the\x0arepository\x20root\x20directory.\x20This\x20kind\x20of\x20version\x20is\x20denoted\x20with\x20the\x20suffix\x0a+incompatible.\x20The\x20version\x20tag\x20itself\x20must\x20not\x20have\x20the\x20suffix.\x20See\x0aCompatibility\x20with\x20non-module\x20repositories.

\x0a

Once\x20a\x20tag\x20is\x20created,\x20it\x20should\x20not\x20be\x20deleted\x20or\x20changed\x20to\x20a\x20different\x0arevision.\x20Versions\x20are\x20authenticated\x20to\x20ensure\x20safe,\x0arepeatable\x20builds.\x20If\x20a\x20tag\x20is\x20modified,\x20clients\x20may\x20see\x20a\x20security\x20error\x20when\x0adownloading\x20it.\x20Even\x20after\x20a\x20tag\x20is\x20deleted,\x20its\x20content\x20may\x20remain\x0aavailable\x20on\x20module\x20proxies.

\x0aMapping\x20pseudo-versions\x20to\x20commits\x0a

The\x20go\x20command\x20may\x20check\x20out\x20a\x20module\x20within\x20a\x20repository\x20at\x20a\x20specific\x0arevision,\x20encoded\x20as\x20a\x20pseudo-version\x20like\x0av1.3.2-0.20191109021931-daa7c04131f5.

\x0a

The\x20last\x2012\x20characters\x20of\x20the\x20pseudo-version\x20(daa7c04131f5\x20in\x20the\x20example\x0aabove)\x20indicate\x20a\x20revision\x20in\x20the\x20repository\x20to\x20check\x20out.\x20The\x20meaning\x20of\x20this\x0adepends\x20on\x20the\x20version\x20control\x20system.\x20For\x20Git\x20and\x20Mercurial,\x20this\x20is\x20a\x20prefix\x0aof\x20a\x20commit\x20hash.\x20For\x20Subversion,\x20this\x20is\x20a\x20zero-padded\x20revision\x20number.

\x0a

Before\x20checking\x20out\x20a\x20commit,\x20the\x20go\x20command\x20verifies\x20that\x20the\x20timestamp\x0a(20191109021931\x20above)\x20matches\x20the\x20commit\x20date.\x20It\x20also\x20verifies\x20that\x20the\x20base\x0aversion\x20(v1.3.1,\x20the\x20version\x20before\x20v1.3.2\x20in\x20the\x20example\x20above)\x20corresponds\x0ato\x20a\x20semantic\x20version\x20tag\x20that\x20is\x20an\x20ancestor\x20of\x20the\x20commit.\x20These\x20checks\x20ensure\x0athat\x20module\x20authors\x20have\x20full\x20control\x20over\x20how\x20pseudo-versions\x20compare\x20with\x0aother\x20released\x20versions.

\x0a

See\x20Pseudo-versions\x20for\x20more\x20information.

\x0aMapping\x20branches\x20and\x20commits\x20to\x20versions\x0a

A\x20module\x20may\x20be\x20checked\x20out\x20at\x20a\x20specific\x20branch,\x20tag,\x20or\x20revision\x20using\x20a\x0aversion\x20query.

\x0a
go\x20get\x20example.com/mod@master\x0a
\x0a

The\x20go\x20command\x20converts\x20these\x20names\x20into\x20canonical\x0aversions\x20that\x20can\x20be\x20used\x20with\x20minimal\x20version\x0aselection\x20(MVS).\x20MVS\x20depends\x20on\x20the\x20ability\x20to\x0aorder\x20versions\x20unambiguously.\x20Branch\x20names\x20and\x20revisions\x20can't\x20be\x20compared\x0areliably\x20over\x20time,\x20since\x20they\x20depend\x20on\x20repository\x20structure\x20which\x20may\x20change.

\x0a

If\x20a\x20revision\x20is\x20tagged\x20with\x20one\x20or\x20more\x20semantic\x20version\x20tags\x20like\x20v1.2.3,\x0athe\x20tag\x20for\x20the\x20highest\x20valid\x20version\x20will\x20be\x20used.\x20The\x20go\x20command\x20only\x0aconsiders\x20semantic\x20version\x20tags\x20that\x20could\x20belong\x20to\x20the\x20target\x20module;\x20for\x0aexample,\x20the\x20tag\x20v1.5.2\x20would\x20not\x20be\x20considered\x20for\x20example.com/mod/v2\x20since\x0athe\x20major\x20version\x20doesn't\x20match\x20the\x20module\x20path's\x20suffix.

\x0a

If\x20a\x20revision\x20is\x20not\x20tagged\x20with\x20a\x20valid\x20semantic\x20version\x20tag,\x20the\x20go\x20command\x0awill\x20generate\x20a\x20pseudo-version.\x20If\x20the\x20revision\x20has\x0aancestors\x20with\x20valid\x20semantic\x20version\x20tags,\x20the\x20highest\x20ancestor\x20version\x20will\x20be\x0aused\x20as\x20the\x20pseudo-version\x20base.\x20See\x20Pseudo-versions.

\x0aModule\x20directories\x20within\x20a\x20repository\x0a

Once\x20a\x20module's\x20repository\x20has\x20been\x20checked\x20out\x20at\x20a\x20specific\x20revision,\x20the\x20go\x0acommand\x20must\x20locate\x20the\x20directory\x20that\x20contains\x20the\x20module's\x20go.mod\x20file\x0a(the\x20module's\x20root\x20directory).

\x0a

Recall\x20that\x20a\x20module\x20path\x20consists\x20of\x20three\x20parts:\x20a\x0arepository\x20root\x20path\x20(corresponding\x20to\x20the\x20repository\x20root\x20directory),\x0aa\x20module\x20subdirectory,\x20and\x20a\x20major\x20version\x20suffix\x20(only\x20for\x20modules\x20released\x20at\x0av2\x20or\x20higher).

\x0a

For\x20most\x20modules,\x20the\x20module\x20path\x20is\x20equal\x20to\x20the\x20repository\x20root\x20path,\x20so\x0athe\x20module's\x20root\x20directory\x20is\x20the\x20repository's\x20root\x20directory.

\x0a

Modules\x20are\x20sometimes\x20defined\x20in\x20repository\x20subdirectories.\x20This\x20is\x20typically\x0adone\x20for\x20large\x20repositories\x20with\x20multiple\x20components\x20that\x20need\x20to\x20be\x20released\x0aand\x20versioned\x20indepently.\x20Such\x20a\x20module\x20is\x20expected\x20to\x20be\x20found\x20in\x20a\x0asubdirectory\x20that\x20matches\x20the\x20part\x20of\x20the\x20module's\x20path\x20after\x20the\x20repository\x0aroot\x20path.\x20\x20For\x20example,\x20suppose\x20the\x20module\x20example.com/monorepo/foo/bar\x20is\x20in\x0athe\x20repository\x20with\x20root\x20path\x20example.com/monorepo.\x20Its\x20go.mod\x20file\x20must\x20be\x0ain\x20the\x20foo/bar\x20subdirectory.

\x0a

If\x20a\x20module\x20is\x20released\x20at\x20major\x20version\x20v2\x20or\x20higher,\x20its\x20path\x20must\x20have\x20a\x0amajor\x20version\x20suffix.\x20A\x20module\x20with\x20a\x20major\x20version\x0asuffix\x20may\x20be\x20defined\x20in\x20one\x20of\x20two\x20subdirectories:\x20one\x20with\x20the\x20suffix,\x0aand\x20one\x20without.\x20For\x20example,\x20suppose\x20a\x20new\x20version\x20of\x20the\x20module\x20above\x20is\x0areleased\x20with\x20the\x20path\x20example.com/monorepo/foo/bar/v2.\x20Its\x20go.mod\x20file\x0amay\x20be\x20in\x20either\x20foo/bar\x20or\x20foo/bar/v2.

\x0a

Subdirectories\x20with\x20a\x20major\x20version\x20suffix\x20are\x20major\x20version\x0asubdirectories.\x20They\x20may\x20be\x20used\x20to\x20develop\x20multiple\x20major\x20versions\x20of\x20a\x0amodule\x20on\x20a\x20single\x20branch.\x20This\x20may\x20be\x20unnecessary\x20when\x20development\x20of\x20multiple\x0amajor\x20versions\x20proceeds\x20on\x20separate\x20branches.\x20However,\x20major\x20version\x0asubdirectories\x20have\x20an\x20important\x20property:\x20in\x20GOPATH\x20mode,\x20package\x20import\x0apaths\x20exactly\x20match\x20directories\x20under\x20GOPATH/src.\x20The\x20go\x20command\x20provides\x0aminimal\x20module\x20compatibility\x20in\x20GOPATH\x20mode\x20(see\x20Compatibility\x20with\x0anon-module\x20repositories),\x20so\x20major\x20version\x0asubdirectories\x20aren't\x20always\x20necessary\x20for\x20compatibility\x20with\x20projects\x20built\x20in\x0aGOPATH\x20mode.\x20Older\x20tools\x20that\x20don't\x20support\x20minimal\x20module\x20compatibility\x0amay\x20have\x20problems\x20though.

\x0a

Once\x20the\x20go\x20command\x20has\x20found\x20the\x20module\x20root\x20directory,\x20it\x20creates\x20a\x20.zip\x0afile\x20of\x20the\x20contents\x20of\x20the\x20directory,\x20then\x20extracts\x20the\x20.zip\x20file\x20into\x20the\x0amodule\x20cache.\x20See\x20File\x20path\x20and\x20size\x20constraints)\x0afor\x20details\x20on\x20what\x20files\x20may\x20be\x20included\x20in\x20the\x20.zip\x20file.\x20The\x20contents\x20of\x0athe\x20.zip\x20file\x20are\x20authenticated\x20before\x20extraction\x20into\x20the\x0amodule\x20cache\x20the\x20same\x20way\x20they\x20would\x20be\x20if\x20the\x20.zip\x20file\x20were\x20downloaded\x20from\x0aa\x20proxy.

\x0aModule\x20zip\x20files\x0a

Module\x20versions\x20are\x20distributed\x20as\x20.zip\x20files.\x20There\x20is\x20rarely\x20any\x20need\x20to\x0ainteract\x20directly\x20with\x20these\x20files,\x20since\x20the\x20go\x20command\x20creates,\x20downloads,\x0aand\x20extracts\x20them\x20automatically\x20from\x20module\x20proxies\x20and\x0aversion\x20control\x20repositories.\x20However,\x20it's\x20still\x20useful\x20to\x20know\x20about\x20these\x0afiles\x20to\x20understand\x20cross-platform\x20compatibility\x20constraints\x20or\x20when\x0aimplementing\x20a\x20module\x20proxy.

\x0a

The\x20go\x20mod\x20download\x20command\x20downloads\x20zip\x20files\x0afor\x20one\x20or\x20more\x20modules,\x20then\x20extracts\x20those\x20files\x20into\x20the\x20module\x0acache.\x20Depending\x20on\x20GOPROXY\x20and\x20other\x20environment\x0avariables,\x20the\x20go\x20command\x20may\x20either\x20download\x0azip\x20files\x20from\x20a\x20proxy\x20or\x20clone\x20source\x20control\x20repositories\x20and\x20create\x0azip\x20files\x20from\x20them.\x20The\x20-json\x20flag\x20may\x20be\x20used\x20to\x20find\x20the\x20location\x20of\x0adownload\x20zip\x20files\x20and\x20their\x20extracted\x20contents\x20in\x20the\x20module\x20cache.

\x0a

The\x20golang.org/x/mod/zip\x0apackage\x20may\x20be\x20used\x20to\x20create,\x20extract,\x20or\x20check\x20contents\x20of\x20zip\x20files\x0aprogrammatically.

\x0aFile\x20path\x20and\x20size\x20constraints\x0a

There\x20are\x20a\x20number\x20of\x20restrictions\x20on\x20the\x20content\x20of\x20module\x20zip\x20files.\x20These\x0aconstraints\x20ensure\x20that\x20zip\x20files\x20can\x20be\x20extracted\x20safely\x20and\x20consistently\x20on\x0aa\x20wide\x20range\x20of\x20platforms.

\x0a
    \x0a
  • A\x20module\x20zip\x20file\x20may\x20be\x20at\x20most\x20500\x20MiB\x20in\x20size.\x20The\x20total\x20uncompressed\x20size\x0aof\x20its\x20files\x20is\x20also\x20limited\x20to\x20500\x20MiB.\x20go.mod\x20files\x20are\x20limited\x20to\x2016\x20MiB.\x0aLICENSE\x20files\x20are\x20also\x20limited\x20to\x2016\x20MiB.\x20These\x20limits\x20exist\x20to\x20mitigate\x0adenial\x20of\x20service\x20attacks\x20on\x20users,\x20proxies,\x20and\x20other\x20parts\x20of\x20the\x20module\x0aecosystem.\x20Repositories\x20that\x20contain\x20more\x20than\x20500\x20MiB\x20of\x20files\x20in\x20a\x20module\x0adirectory\x20tree\x20should\x20tag\x20module\x20versions\x20at\x20commits\x20that\x20only\x20include\x20files\x0aneeded\x20to\x20build\x20the\x20module's\x20packages;\x20videos,\x20models,\x20and\x20other\x20large\x20assets\x0aare\x20usually\x20not\x20needed\x20for\x20builds.
  • \x0a
  • Each\x20file\x20within\x20a\x20module\x20zip\x20file\x20must\x20begin\x20with\x20the\x20prefix\x0a$module@$version/\x20where\x20$module\x20is\x20the\x20module\x20path\x20and\x20$version\x20is\x20the\x0aversion,\x20for\x20example,\x20golang.org/x/mod@v0.3.0/.\x20The\x20module\x20path\x20must\x20be\x0avalid,\x20the\x20version\x20must\x20be\x20valid\x20and\x20canonical,\x20and\x20the\x20version\x20must\x20match\x20the\x0amodule\x20path's\x20major\x20version\x20suffix.\x20See\x20Module\x20paths\x20and\x0aversions\x20for\x20specific\x20definitions\x20and\x20restrictions.
  • \x0a
  • File\x20modes,\x20timestamps,\x20and\x20other\x20metadata\x20are\x20ignored.
  • \x0a
  • Empty\x20directories\x20(entries\x20with\x20paths\x20ending\x20with\x20a\x20slash)\x20may\x20be\x20included\x0ain\x20module\x20zip\x20files\x20but\x20are\x20not\x20extracted.\x20The\x20go\x20command\x20does\x20not\x20include\x0aempty\x20directories\x20in\x20zip\x20files\x20it\x20creates.
  • \x0a
  • Symbolic\x20links\x20and\x20other\x20irregular\x20files\x20are\x20ignored\x20when\x20creating\x20zip\x20files,\x0asince\x20they\x20aren't\x20portable\x20across\x20operating\x20systems\x20and\x20file\x20systems,\x20and\x0athere's\x20no\x20portable\x20way\x20to\x20represent\x20them\x20in\x20the\x20zip\x20file\x20format.
  • \x0a
  • No\x20two\x20files\x20within\x20a\x20zip\x20file\x20may\x20have\x20paths\x20equal\x20under\x20Unicode\x20case-folding\x0a(see\x20strings.EqualFold).\x0aThis\x20ensures\x20that\x20zip\x20files\x20can\x20be\x20extracted\x20on\x20case-insensitive\x20file\x20systems\x0awithout\x20collisions.
  • \x0a
  • A\x20go.mod\x20file\x20may\x20or\x20may\x20not\x20appear\x20in\x20the\x20top-level\x20directory\x0a($module@$version/go.mod).\x20If\x20present,\x20it\x20must\x20have\x20the\x20name\x20go.mod\x20(all\x0alowercase).\x20Files\x20named\x20go.mod\x20are\x20not\x20allowed\x20in\x20any\x20other\x20directory.
  • \x0a
  • File\x20and\x20directory\x20names\x20within\x20a\x20module\x20may\x20consist\x20of\x20Unicode\x20letters,\x20ASCII\x0adigits,\x20the\x20ASCII\x20space\x20character\x20(U+0020),\x20and\x20the\x20ASCII\x20punctuation\x0acharacters\x20!#$%&()+,-.=@[]^_{}~.\x20Note\x20that\x20package\x20paths\x20may\x20not\x20contain\x20all\x0athese\x20all\x20these\x20characters.\x20See\x0amodule.CheckFilePath\x0aand\x0amodule.CheckImportPath\x0afor\x20the\x20differences.
  • \x0a
  • A\x20file\x20or\x20directory\x20name\x20up\x20to\x20the\x20first\x20dot\x20must\x20not\x20be\x20a\x20reserved\x20file\x20name\x0aon\x20Windows,\x20regardless\x20of\x20case\x20(CON,\x20com1,\x20NuL,\x20and\x20so\x20on).
  • \x0a
\x0aPrivate\x20modules\x0a

Go\x20modules\x20are\x20frequently\x20developed\x20and\x20distributed\x20on\x20version\x20control\x20servers\x0aand\x20module\x20proxies\x20that\x20aren't\x20available\x20on\x20the\x20public\x20internet.\x20The\x20go\x0acommand\x20can\x20download\x20and\x20build\x20modules\x20from\x20private\x20sources,\x20though\x20it\x20usually\x0arequires\x20some\x20configuration.

\x0a

The\x20environment\x20variables\x20below\x20may\x20be\x20used\x20to\x20configure\x20access\x20to\x20private\x0amodules.\x20See\x20Environment\x20variables\x20for\x20details.\x20See\x0aalso\x20Privacy\x20for\x20information\x20on\x20controlling\x20information\x20sent\x20to\x0apublic\x20servers.

\x0a
    \x0a
  • GOPROXY\x20\xe2\x80\x94\x20list\x20of\x20module\x20proxy\x20URLs.\x20The\x20go\x20command\x20will\x20attempt\x20to\x0adownload\x20modules\x20from\x20each\x20server\x20in\x20sequence.\x20The\x20keyword\x20direct\x20instructs\x0athe\x20go\x20command\x20to\x20download\x20modules\x20from\x20version\x20control\x20repositories\x0awhere\x20they're\x20developed\x20instead\x20of\x20using\x20a\x20proxy.
  • \x0a
  • GOPRIVATE\x20\xe2\x80\x94\x20list\x20of\x20glob\x20patterns\x20of\x20module\x20path\x20prefixes\x20that\x20should\x20be\x0aconsidered\x20private.\x20Acts\x20as\x20a\x20default\x20value\x20for\x20GONOPROXY\x20and\x20GONOSUMDB.
  • \x0a
  • GONOPROXY\x20\xe2\x80\x94\x20list\x20of\x20glob\x20patterns\x20of\x20module\x20path\x20prefixes\x20that\x20should\x20not\x20be\x0adownloaded\x20from\x20a\x20proxy.\x20The\x20go\x20command\x20will\x20download\x20matching\x20modules\x20from\x0aversion\x20control\x20repositories\x20where\x20they're\x20developed,\x20regardless\x20of\x20GOPROXY.
  • \x0a
  • GONOSUMDB\x20\xe2\x80\x94\x20list\x20of\x20glob\x20patterns\x20of\x20module\x20path\x20prefixes\x20that\x20should\x20not\x20be\x0achecked\x20using\x20the\x20public\x20checksum\x20database,\x0asum.golang.org.
  • \x0a
  • GOINSECURE\x20\xe2\x80\x94\x20list\x20of\x20glob\x20patterns\x20of\x20module\x20path\x20prefixes\x20that\x20may\x20be\x0aretrieved\x20over\x20HTTP\x20and\x20other\x20insecure\x20protocols.
  • \x0a
\x0a

These\x20variables\x20may\x20be\x20set\x20in\x20the\x20development\x20environment\x20(for\x20example,\x20in\x20a\x0a.profile\x20file),\x20or\x20they\x20may\x20be\x20set\x20permanently\x20with\x20go\x20env\x20-w.

\x0a

The\x20rest\x20of\x20this\x20section\x20describes\x20common\x20patterns\x20for\x20providing\x20access\x20to\x0aprivate\x20module\x20proxies\x20and\x20version\x20control\x20repositories.

\x0aPrivate\x20proxy\x20serving\x20all\x20modules\x0a

A\x20central\x20private\x20proxy\x20server\x20that\x20serves\x20all\x20modules\x20(public\x20and\x20private)\x0aprovides\x20the\x20most\x20control\x20for\x20administrators\x20and\x20requires\x20the\x20least\x0aconfiguration\x20for\x20individual\x20developers.

\x0a

To\x20configure\x20the\x20go\x20command\x20to\x20use\x20such\x20a\x20server,\x20set\x20the\x20following\x0aenvironment\x20variables,\x20replacing\x20https://proxy.corp.example.com\x20with\x20your\x0aproxy\x20URL\x20and\x20corp.example.com\x20with\x20your\x20module\x20prefix:

\x0a
GOPROXY=https://proxy.corp.example.com\x0aGONOSUMDB=corp.example.com\x0a
\x0a

The\x20GOPROXY\x20setting\x20instructs\x20the\x20go\x20command\x20to\x20only\x20download\x20modules\x20from\x0ahttps://proxy.corp.example.com;\x20the\x20go\x20command\x20will\x20not\x20connect\x20to\x20other\x0aproxies\x20or\x20version\x20control\x20repositories.

\x0a

The\x20GONOSUMDB\x20setting\x20instructs\x20the\x20go\x20command\x20not\x20to\x20use\x20the\x20public\x0achecksum\x20database\x20to\x20authenticate\x20modules\x20with\x20paths\x20starting\x20with\x0acorp.example.com.

\x0a

A\x20proxy\x20running\x20in\x20this\x20configuration\x20will\x20likely\x20need\x20read\x20access\x20to\x0aprivate\x20version\x20control\x20servers.\x20It\x20will\x20also\x20need\x20access\x20to\x20the\x20public\x20internet\x0ato\x20download\x20new\x20versions\x20of\x20public\x20modules.

\x0a

There\x20are\x20several\x20existing\x20implementations\x20of\x20GOPROXY\x20servers\x20that\x20may\x20be\x20used\x0athis\x20way.\x20A\x20minimal\x20implementation\x20would\x20serve\x20files\x20from\x20a\x20module\x0acache\x20directory\x20and\x20would\x20use\x20go\x20mod\x20download\x20(with\x20suitable\x20configuration)\x20to\x20retrieve\x20missing\x0amodules.

\x0aPrivate\x20proxy\x20serving\x20private\x20modules\x0a

A\x20private\x20proxy\x20server\x20may\x20serve\x20private\x20modules\x20without\x20also\x20serving\x20publicly\x0aavailable\x20modules.\x20The\x20go\x20command\x20can\x20be\x20configured\x20to\x20fall\x20back\x20to\x0apublic\x20sources\x20for\x20modules\x20that\x20aren't\x20available\x20on\x20the\x20private\x20server.

\x0a

To\x20configure\x20the\x20go\x20command\x20to\x20work\x20this\x20way,\x20set\x20the\x20following\x20environment\x0avariables,\x20replacing\x20https://proxy.corp.example.com\x20with\x20the\x20proxy\x20URL\x20and\x0acorp.example.com\x20with\x20the\x20module\x20prefix:

\x0a
GOPROXY=https://proxy.corp.example.com,https://proxy.golang.org,direct\x0aGONOSUMDB=corp.example.com\x0a
\x0a

The\x20GOPROXY\x20setting\x20instructs\x20the\x20go\x20command\x20to\x20try\x20to\x20download\x20modules\x20from\x0ahttps://proxy.corp.example.com\x20first.\x20If\x20that\x20server\x20responds\x20with\x20404\x20(Not\x0aFound)\x20or\x20410\x20(Gone),\x20the\x20go\x20command\x20will\x20fall\x20back\x20to\x0ahttps://proxy.golang.org,\x20then\x20to\x20direct\x20connections\x20to\x20repositories.

\x0a

The\x20GONOSUMDB\x20setting\x20instructs\x20the\x20go\x20command\x20not\x20to\x20use\x20the\x20public\x20checksum\x0adatabase\x20to\x20authenticate\x20modules\x20whose\x20paths\x20start\x20with\x20corp.example.com.

\x0a

Note\x20that\x20a\x20proxy\x20used\x20in\x20this\x20configuration\x20may\x20still\x20control\x20access\x20to\x20public\x0amodules,\x20even\x20though\x20it\x20doesn't\x20serve\x20them.\x20If\x20the\x20proxy\x20responds\x20to\x20a\x20request\x0awith\x20an\x20error\x20status\x20other\x20than\x20404\x20or\x20410,\x20the\x20go\x20command\x20will\x20not\x20fall\x20back\x0ato\x20later\x20entries\x20in\x20the\x20GOPROXY\x20list.\x20For\x20example,\x20the\x20proxy\x20could\x20respond\x0awith\x20403\x20(Forbidden)\x20for\x20a\x20module\x20with\x20an\x20unsuitable\x20license\x20or\x20with\x20known\x0asecurity\x20vulnerabilities.

\x0aDirect\x20access\x20to\x20private\x20modules\x0a

The\x20go\x20command\x20may\x20be\x20configured\x20to\x20bypass\x20public\x20proxies\x20and\x20download\x20private\x0amodules\x20directly\x20from\x20version\x20control\x20servers.\x20This\x20is\x20useful\x20when\x20running\x20a\x0aprivate\x20proxy\x20server\x20is\x20not\x20feasible.

\x0a

To\x20configure\x20the\x20go\x20command\x20to\x20work\x20this\x20way,\x20set\x20GOPRIVATE,\x20replacing\x0acorp.example.com\x20the\x20private\x20module\x20prefix:

\x0a
GOPRIVATE=corp.example.com\x0a
\x0a

The\x20GOPROXY\x20variable\x20does\x20not\x20need\x20to\x20be\x20changed\x20in\x20this\x20situation.\x20It\x0adefaults\x20to\x20https://proxy.golang.org,direct,\x20which\x20instructs\x20the\x20go\x20command\x0ato\x20attempt\x20to\x20download\x20modules\x20from\x20https://proxy.golang.org\x20first,\x20then\x20fall\x0aback\x20to\x20a\x20direct\x20connection\x20if\x20that\x20proxy\x20responds\x20with\x20404\x20(Not\x20Found)\x20or\x20410\x0a(Gone).

\x0a

The\x20GOPRIVATE\x20setting\x20instructs\x20the\x20go\x20command\x20not\x20to\x20connect\x20to\x20a\x20proxy\x20or\x0ato\x20the\x20checksum\x20database\x20for\x20modules\x20starting\x20with\x20corp.example.com.

\x0a

An\x20internal\x20HTTP\x20server\x20may\x20still\x20be\x20needed\x20to\x20resolve\x20module\x20paths\x20to\x0arepository\x20URLs.\x20For\x20example,\x20when\x20the\x20go\x20command\x20downloads\x20the\x0amodule\x20corp.example.com/mod,\x20it\x20will\x20send\x20a\x20GET\x20request\x20to\x0ahttps://corp.example.com/mod?go-get=1,\x20and\x20it\x20will\x20look\x20for\x20the\x20repository\x20URL\x0ain\x20the\x20response.\x20To\x20avoid\x20this\x20requirement,\x20ensure\x20that\x20each\x20private\x20module\x20path\x0ahas\x20a\x20VCS\x20suffix\x20(like\x20.git)\x20marking\x20the\x20repository\x20root\x20prefix.\x20For\x20example,\x0awhen\x20the\x20go\x20command\x20downloads\x20the\x20module\x20corp.example.com/repo.git/mod,\x20it\x0awill\x20clone\x20the\x20Git\x20repository\x20at\x20https://corp.example.com/repo.git\x20or\x0assh://corp.example.com/repo.git\x20without\x20needing\x20to\x20make\x20additional\x20requests.

\x0a

Developers\x20will\x20need\x20read\x20access\x20to\x20repositories\x20containing\x20private\x20modules.\x0aThis\x20may\x20be\x20configured\x20in\x20global\x20VCS\x20configuration\x20files\x20like\x20.gitconfig.\x0aIt's\x20best\x20if\x20VCS\x20tools\x20are\x20configured\x20not\x20to\x20need\x20interactive\x20authentication\x0aprompts.\x20By\x20default,\x20when\x20invoking\x20Git,\x20the\x20go\x20command\x20disables\x20interactive\x0aprompts\x20by\x20setting\x20GIT_TERMINAL_PROMPT=0,\x20but\x20it\x20respects\x20explicit\x20settings.

\x0aPassing\x20credentials\x20to\x20private\x20proxies\x0a

The\x20go\x20command\x20supports\x20HTTP\x20basic\x0aauthentication\x20when\x0acommunicating\x20with\x20proxy\x20servers.

\x0a

Credentials\x20may\x20be\x20specified\x20in\x20a\x20.netrc\x0afile.\x0aFor\x20example,\x20a\x20.netrc\x20file\x20containing\x20the\x20lines\x20below\x20would\x20configure\x20the\x20go\x0acommand\x20to\x20connect\x20to\x20the\x20machine\x20proxy.corp.example.com\x20with\x20the\x20given\x0ausername\x20and\x20password.

\x0a
machine\x20proxy.corp.example.com\x0alogin\x20jrgopher\x0apassword\x20hunter2\x0a
\x0a

The\x20location\x20of\x20the\x20file\x20may\x20be\x20set\x20with\x20the\x20NETRC\x20environment\x20variable.\x20If\x0aNETRC\x20is\x20not\x20set,\x20the\x20go\x20command\x20will\x20read\x20$HOME/.netrc\x20on\x20UNIX-like\x0aplatforms\x20or\x20%USERPROFILE%\\_netrc\x20on\x20Windows.

\x0a

Fields\x20in\x20.netrc\x20are\x20separated\x20with\x20spaces,\x20tabs,\x20and\x20newlines.\x20Unfortunately,\x0athese\x20characters\x20cannot\x20be\x20used\x20in\x20usernames\x20or\x20passwords.\x20Note\x20also\x20that\x20the\x0amachine\x20name\x20cannot\x20be\x20a\x20full\x20URL,\x20so\x20it's\x20not\x20possible\x20to\x20specify\x20different\x0ausernames\x20and\x20passwords\x20for\x20different\x20paths\x20on\x20the\x20same\x20machine.

\x0a

Alternatively,\x20credentials\x20may\x20be\x20specified\x20directly\x20in\x20GOPROXY\x20URLs.\x20For\x0aexample:

\x0a
GOPROXY=https://jrgopher:hunter2@proxy.corp.example.com\x0a
\x0a

Use\x20caution\x20when\x20taking\x20this\x20approach:\x20environment\x20variables\x20may\x20be\x20appear\x0ain\x20shell\x20history\x20and\x20in\x20logs.

\x0aModule\x20cache\x0a

The\x20module\x20cache\x20is\x20the\x20directory\x20where\x20the\x20go\x20command\x20stores\x0adownloaded\x20module\x20files.\x20The\x20module\x20cache\x20is\x20distinct\x20from\x20the\x20build\x20cache,\x0awhich\x20contains\x20compiled\x20packages\x20and\x20other\x20build\x20artifacts.

\x0a

The\x20default\x20location\x20of\x20the\x20module\x20cache\x20is\x20$GOPATH/pkg/mod.\x20To\x20use\x20a\x0adifferent\x20location,\x20set\x20the\x20GOMODCACHE\x20environment\x0avariable.

\x0a

The\x20module\x20cache\x20has\x20no\x20maximum\x20size,\x20and\x20the\x20go\x20command\x20does\x20not\x20remove\x20its\x0acontents\x20automatically.

\x0a

The\x20cache\x20may\x20be\x20shared\x20by\x20multiple\x20Go\x20projects\x20developed\x20on\x20the\x20same\x20machine.\x0aThe\x20go\x20command\x20will\x20use\x20the\x20same\x20cache\x20regardless\x20of\x20the\x20location\x20of\x20the\x0amain\x20module.\x20Multiple\x20instances\x20of\x20the\x20go\x20command\x20may\x20safely\x20access\x20the\x0asame\x20module\x20cache\x20at\x20the\x20same\x20time.

\x0a

The\x20go\x20command\x20creates\x20module\x20source\x20files\x20and\x20directories\x20in\x20the\x20cache\x20with\x0aread-only\x20permissions\x20to\x20prevent\x20accidental\x20changes\x20to\x20modules\x20after\x20they're\x0adownloaded.\x20This\x20has\x20the\x20unfortunate\x20side-effect\x20of\x20making\x20the\x20cache\x20difficult\x0ato\x20delete\x20with\x20commands\x20like\x20rm\x20-rf.\x20The\x20cache\x20may\x20instead\x20be\x20deleted\x20with\x0ago\x20clean\x20-modcache.\x20Alternatively,\x20when\x20the\x0a-modcacherw\x20flag\x20is\x20used,\x20the\x20go\x20command\x20will\x20create\x20new\x20directories\x20with\x0aread-write\x20permissions.\x20This\x20increases\x20the\x20risk\x20of\x20editors,\x20tests,\x20and\x20other\x0aprograms\x20modifying\x20files\x20in\x20the\x20module\x20cache.\x20The\x20go\x20mod\x20verify\x20command\x20may\x20be\x20used\x20to\x20detect\x20modifications\x20to\x0adependencies\x20of\x20the\x20main\x20module.\x20It\x20scans\x20the\x20extracted\x20contents\x20of\x20each\x0amodule\x20dependency\x20and\x20confirms\x20they\x20match\x20the\x20expected\x20hash\x20in\x20go.sum.

\x0a

The\x20table\x20below\x20explains\x20the\x20purpose\x20of\x20most\x20files\x20in\x20the\x20module\x20cache.\x20Some\x0atransient\x20files\x20(lock\x20files,\x20temporary\x20directories)\x20are\x20omitted.\x20For\x20each\x20path,\x0a$module\x20is\x20a\x20module\x20path,\x20and\x20$version\x20is\x20a\x20version.\x20Paths\x20ending\x20with\x0aslashes\x20(/)\x20are\x20directories.\x20Capital\x20letters\x20in\x20module\x20paths\x20and\x20versions\x20are\x0aescaped\x20using\x20exclamation\x20points\x20(Azure\x20is\x20escaped\x20as\x20!azure)\x20to\x20avoid\x0aconflicts\x20on\x20case-insensitive\x20file\x20systems.

\x0a\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20Path\x0a\x20\x20\x20\x20\x20\x20Description\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$module@$version/\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Directory\x20containing\x20extracted\x20contents\x20of\x20a\x20module\x20.zip\x0a\x20\x20\x20\x20\x20\x20\x20\x20file.\x20This\x20serves\x20as\x20a\x20module\x20root\x20directory\x20for\x20a\x20downloaded\x20module.\x20It\x0a\x20\x20\x20\x20\x20\x20\x20\x20won't\x20contain\x20contain\x20a\x20go.mod\x20file\x20if\x20the\x20original\x20module\x0a\x20\x20\x20\x20\x20\x20\x20\x20didn't\x20have\x20one.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20cache/download/\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Directory\x20containing\x20files\x20downloaded\x20from\x20module\x20proxies\x20and\x20files\x0a\x20\x20\x20\x20\x20\x20\x20\x20derived\x20from\x20version\x20control\x20systems.\x20The\x20layout\x20of\x0a\x20\x20\x20\x20\x20\x20\x20\x20this\x20directory\x20follows\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20GOPROXY\x20protocol,\x20so\x0a\x20\x20\x20\x20\x20\x20\x20\x20this\x20directory\x20may\x20be\x20used\x20as\x20a\x20proxy\x20when\x20served\x20by\x20an\x20HTTP\x20file\x0a\x20\x20\x20\x20\x20\x20\x20\x20server\x20or\x20when\x20referenced\x20with\x20a\x20file://\x20URL.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20cache/download/$module/@v/list\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20List\x20of\x20known\x20versions\x20(see\x0a\x20\x20\x20\x20\x20\x20\x20\x20GOPROXY\x20protocol).\x20This\x0a\x20\x20\x20\x20\x20\x20\x20\x20may\x20change\x20over\x20time,\x20so\x20the\x20go\x20command\x20usually\x20fetches\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20new\x20copy\x20instead\x20of\x20re-using\x20this\x20file.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20cache/download/$module/@v/$version.info\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20JSON\x20metadata\x20about\x20the\x20version.\x20(see\x0a\x20\x20\x20\x20\x20\x20\x20\x20GOPROXY\x20protocol).\x20This\x0a\x20\x20\x20\x20\x20\x20\x20\x20may\x20change\x20over\x20time,\x20so\x20the\x20go\x20command\x20usually\x20fetches\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20new\x20copy\x20instead\x20of\x20re-using\x20this\x20file.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20cache/download/$module/@v/$version.mod\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20The\x20go.mod\x20file\x20for\x20this\x20version\x20(see\x0a\x20\x20\x20\x20\x20\x20\x20\x20GOPROXY\x20protocol).\x20If\x0a\x20\x20\x20\x20\x20\x20\x20\x20the\x20original\x20module\x20did\x20not\x20have\x20a\x20go.mod\x20file,\x20this\x20is\x0a\x20\x20\x20\x20\x20\x20\x20\x20a\x20synthesized\x20file\x20with\x20no\x20requirements.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20cache/download/$module/@v/$version.zip\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20The\x20zipped\x20contents\x20of\x20the\x20module\x20(see\x0a\x20\x20\x20\x20\x20\x20\x20\x20GOPROXY\x20protocol\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20Module\x20zip\x20files).\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20cache/download/$module/@v/$version.ziphash\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20A\x20cryptographic\x20hash\x20of\x20the\x20files\x20in\x20the\x20.zip\x20file.\x0a\x20\x20\x20\x20\x20\x20\x20\x20Note\x20that\x20the\x20.zip\x20file\x20itself\x20is\x20not\x20hashed,\x20so\x20file\x0a\x20\x20\x20\x20\x20\x20\x20\x20order,\x20compression,\x20alignment,\x20and\x20metadata\x20don't\x20affect\x20the\x20hash.\x0a\x20\x20\x20\x20\x20\x20\x20\x20When\x20using\x20a\x20module,\x20the\x20go\x20command\x20verifies\x20this\x20hash\x0a\x20\x20\x20\x20\x20\x20\x20\x20matches\x20the\x20corresponding\x20line\x20in\x0a\x20\x20\x20\x20\x20\x20\x20\x20go.sum.\x20The\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20mod\x20verify\x20command\x20checks\x0a\x20\x20\x20\x20\x20\x20\x20\x20that\x20the\x20hashes\x20of\x20module\x20.zip\x20files\x20and\x20extracted\x0a\x20\x20\x20\x20\x20\x20\x20\x20directories\x20match\x20these\x20files.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20cache/download/sumdb/\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Directory\x20containing\x20files\x20downloaded\x20from\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20checksum\x20database\x20(typically\x0a\x20\x20\x20\x20\x20\x20\x20\x20sum.golang.org).\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20cache/vcs/\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Contains\x20cloned\x20version\x20control\x20repositories\x20for\x20modules\x20fetched\x0a\x20\x20\x20\x20\x20\x20\x20\x20directly\x20from\x20their\x20sources.\x20Directory\x20names\x20are\x20hex-encoded\x20hashes\x0a\x20\x20\x20\x20\x20\x20\x20\x20derived\x20from\x20the\x20repository\x20type\x20and\x20URL.\x20Repositories\x20are\x20optimized\x0a\x20\x20\x20\x20\x20\x20\x20\x20for\x20size\x20on\x20disk.\x20For\x20example,\x20cloned\x20Git\x20repositories\x20are\x20bare\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20shallow\x20when\x20possible.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x0aAuthenticating\x20modules\x0a\x0a

When\x20deciding\x20whether\x20to\x20trust\x20the\x20source\x20code\x20for\x20a\x20module\x20version\x20just\x0afetched\x20from\x20a\x20proxy\x20or\x20origin\x20server,\x20the\x20go\x20command\x20first\x20consults\x20the\x0ago.sum\x20lines\x20in\x20the\x20go.sum\x20file\x20of\x20the\x20current\x20module.\x20If\x20the\x20go.sum\x20file\x0adoes\x20not\x20contain\x20an\x20entry\x20for\x20that\x20module\x20version,\x20then\x20it\x20may\x20consult\x20the\x0achecksum\x20database.

\x0ago.sum\x20files\x0a

A\x20module\x20may\x20have\x20a\x20text\x20file\x20named\x20go.sum\x20in\x20its\x20root\x20directory,\x20alongside\x0aits\x20go.mod\x20file.\x20The\x20go.sum\x20file\x20contains\x20cryptographic\x20hashes\x20of\x20the\x0amodule's\x20direct\x20and\x20indirect\x20dependencies.\x20go.sum\x20may\x20be\x20empty\x20or\x20absent\x0aif\x20the\x20module\x20has\x20no\x20dependencies\x20or\x20if\x20all\x20dependencies\x20are\x20replaced\x20with\x0alocal\x20directories\x20using\x20replace\x20directives.

\x0a

Each\x20line\x20in\x20go.sum\x20has\x20three\x20fields\x20separated\x20by\x20spaces:\x20a\x20module\x20path,\x0aa\x20version\x20(possibly\x20ending\x20with\x20/go.mod),\x20and\x20a\x20hash.

\x0a
    \x0a
  • The\x20module\x20path\x20is\x20the\x20name\x20of\x20the\x20module\x20the\x20hash\x20belongs\x20to.
  • \x0a
  • The\x20version\x20is\x20the\x20version\x20of\x20the\x20module\x20the\x20hash\x20belongs\x20to.\x20If\x20the\x20version\x0aends\x20with\x20/go.mod,\x20the\x20hash\x20is\x20for\x20the\x20module's\x20go.mod\x20file\x20only;\x0aotherwise,\x20the\x20hash\x20is\x20for\x20the\x20files\x20within\x20the\x20module's\x20.zip\x20file.
  • \x0a
  • The\x20hash\x20column\x20consists\x20of\x20an\x20algorithm\x20name\x20(like\x20h1)\x20and\x20a\x20base64-encoded\x0acryptographic\x20hash,\x20separated\x20by\x20a\x20colon\x20(:).\x20Currently,\x20SHA-256\x20(h1)\x20is\x0athe\x20only\x20supported\x20hash\x20algorithm.\x20If\x20a\x20vulnerability\x20in\x20SHA-256\x20is\x20discovered\x0ain\x20the\x20future,\x20support\x20will\x20be\x20added\x20for\x20another\x20algorithm\x20(named\x20h2\x20and\x0aso\x20on).
  • \x0a
\x0a

When\x20the\x20go\x20command\x20downloads\x20a\x20module\x20.mod\x20or\x20.zip\x20file\x20into\x20the\x20module\x0acache,\x20it\x20computes\x20a\x20hash\x20and\x20checks\x20that\x20the\x20hash\x20matches\x20the\x0acorresponding\x20hash\x20in\x20the\x20main\x20module's\x20go.sum\x20file.\x20For\x20.mod\x20files,\x20the\x0afile\x20contents\x20are\x20hashed.\x20For\x20.zip\x20files,\x20the\x20files\x20within\x20the\x20archive\x20are\x0ahashed.\x20The\x20hash\x20is\x20not\x20affected\x20by\x20file\x20ordering,\x20compression,\x20alignment,\x20or\x0ametadata.\x20See\x20Module\x20zip\x20files\x20for\x20information\x20on\x20which\x20files\x20are\x0aincluded.\x20See\x0agolang.org/x/mod/sumdb/dirhash\x0afor\x20hash\x20implementation\x20details.

\x0a

If\x20the\x20computed\x20hash\x20does\x20not\x20match\x20the\x20corresponding\x20hash\x20in\x20go.sum,\x20the\x20go\x0acommand\x20reports\x20a\x20security\x20error.\x20If\x20the\x20hash\x20is\x20not\x20present\x20in\x20go.sum,\x20the\x0ago\x20command\x20looks\x20up\x20the\x20correct\x20hash\x20in\x20the\x20checksum\x0adatabase\x20(unless\x20the\x20module\x20matches\x20GONOSUMDB\x20or\x0aGOSUMDB\x20is\x20set\x20to\x20off;\x20see\x20Environment\x0avariables).\x20If\x20no\x20mismatch\x20is\x20detected,\x20the\x20go\x0acommand\x20adds\x20the\x20hash\x20to\x20go.sum.

\x0a

The\x20go\x20command\x20does\x20not\x20automatically\x20verify\x20modules\x20already\x20in\x20the\x20cache.\x20By\x0adefault,\x20files\x20and\x20directories\x20in\x20the\x20module\x20cache\x20have\x20read-only\x20permissions\x20to\x0aprevent\x20accidental\x20changes.\x20The\x20go\x20mod\x20verify\x20command\x20may\x20be\x0aused\x20to\x20check\x20that\x20.zip\x20files\x20and\x20extracted\x20directories\x20in\x20the\x20module\x20cache\x0amatch\x20hashes\x20recorded\x20when\x20they\x20were\x20downloaded.

\x0a

The\x20go.sum\x20file\x20may\x20contain\x20hashes\x20for\x20multiple\x20versions\x20of\x20a\x20module.\x20The\x20go\x0acommand\x20may\x20need\x20to\x20load\x20go.mod\x20files\x20from\x20multiple\x20versions\x20of\x20a\x20dependency\x0ain\x20order\x20to\x20perform\x20minimal\x20version\x20selection.\x0ago.sum\x20may\x20also\x20contain\x20hashes\x20for\x20module\x20versions\x20that\x20aren't\x20needed\x20anymore\x0a(for\x20example,\x20after\x20an\x20upgrade).\x20go\x20mod\x20tidy\x20will\x20add\x20missing\x0ahashes\x20and\x20will\x20remove\x20unnecessary\x20hashes\x20from\x20go.sum.

\x0aChecksum\x20database\x0a

The\x20checksum\x20database\x20is\x20a\x20global\x20source\x20of\x20go.sum\x20lines.\x20The\x20go\x20command\x20can\x0ause\x20this\x20in\x20many\x20situations\x20to\x20detect\x20misbehavior\x20by\x20proxies\x20or\x20origin\x20servers.

\x0a

The\x20checksum\x20database\x20allows\x20for\x20global\x20consistency\x20and\x20reliability\x20for\x20all\x0apublicly\x20available\x20module\x20versions.\x20It\x20makes\x20untrusted\x20proxies\x20possible\x20since\x0athey\x20can't\x20serve\x20the\x20wrong\x20code\x20without\x20it\x20going\x20unnoticed.\x20It\x20also\x20ensures\x0athat\x20the\x20bits\x20associated\x20with\x20a\x20specific\x20version\x20do\x20not\x20change\x20from\x20one\x20day\x20to\x0athe\x20next,\x20even\x20if\x20the\x20module's\x20author\x20subsequently\x20alters\x20the\x20tags\x20in\x20their\x0arepository.

\x0a

The\x20checksum\x20database\x20is\x20served\x20by\x20sum.golang.org,\x0awhich\x20is\x20run\x20by\x20Google.\x20It\x20is\x20a\x20Transparent\x0aLog\x20(or\x20\xe2\x80\x9cMerkle\x20Tree\xe2\x80\x9d)\x20of\x20go.sum\x20line\x0ahashes,\x20which\x20is\x20backed\x20by\x20Trillian.\x20The\x0amain\x20advantage\x20of\x20a\x20Merkle\x20tree\x20is\x20that\x20independent\x20auditors\x20can\x20verify\x20that\x20it\x0ahasn't\x20been\x20tampered\x20with,\x20so\x20it\x20is\x20more\x20trustworthy\x20than\x20a\x20simple\x20database.

\x0a

The\x20go\x20command\x20interacts\x20with\x20the\x20checksum\x20database\x20using\x20the\x20protocol\x0aoriginally\x20outlined\x20in\x20Proposal:\x20Secure\x20the\x20Public\x20Go\x20Module\x0aEcosystem.

\x0a

The\x20table\x20below\x20specifies\x20queries\x20that\x20the\x20checksum\x20database\x20must\x20respond\x20to.\x0aFor\x20each\x20path,\x20$base\x20is\x20the\x20path\x20portion\x20of\x20the\x20checksum\x20database\x20URL,\x0a$module\x20is\x20a\x20module\x20path,\x20and\x20$version\x20is\x20a\x20version.\x20For\x20example,\x20if\x20the\x0achecksum\x20database\x20URL\x20is\x20https://sum.golang.org,\x20and\x20the\x20client\x20is\x20requesting\x0athe\x20record\x20for\x20the\x20module\x20golang.org/x/text\x20at\x20version\x20v0.3.2,\x20the\x20client\x0awould\x20send\x20a\x20GET\x20request\x20for\x0ahttps://sum.golang.org/lookup/golang.org/x/text@v0.3.2.

\x0a

To\x20avoid\x20ambiguity\x20when\x20serving\x20from\x20case-insensitive\x20file\x20systems,\x0athe\x20$module\x20and\x20$version\x20elements\x20are\x0acase-encoded\x0aby\x20replacing\x20every\x20uppercase\x20letter\x20with\x20an\x20exclamation\x20mark\x20followed\x20by\x20the\x0acorresponding\x20lower-case\x20letter.\x20This\x20allows\x20modules\x20example.com/M\x20and\x0aexample.com/m\x20to\x20both\x20be\x20stored\x20on\x20disk,\x20since\x20the\x20former\x20is\x20encoded\x20as\x0aexample.com/!m.

\x0a

Parts\x20of\x20the\x20path\x20surrounded\x20by\x20square\x20brakets,\x20like\x20[.p/$W]\x20denote\x20optional\x0avalues.

\x0a\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20Path\x0a\x20\x20\x20\x20\x20\x20Description\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$base/latest\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Returns\x20a\x20signed,\x20encoded\x20tree\x20description\x20for\x20the\x20latest\x20log.\x20This\x0a\x20\x20\x20\x20\x20\x20\x20\x20signed\x20description\x20is\x20in\x20the\x20form\x20of\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20note,\x0a\x20\x20\x20\x20\x20\x20\x20\x20which\x20is\x20text\x20that\x20has\x20been\x20signed\x20by\x20one\x20or\x20more\x20server\x20keys\x20and\x20can\x0a\x20\x20\x20\x20\x20\x20\x20\x20be\x20verified\x20using\x20the\x20server's\x20public\x20key.\x20The\x20tree\x20description\x0a\x20\x20\x20\x20\x20\x20\x20\x20provides\x20the\x20size\x20of\x20the\x20tree\x20and\x20the\x20hash\x20of\x20the\x20tree\x20head\x20at\x20that\x0a\x20\x20\x20\x20\x20\x20\x20\x20size.\x20This\x20encoding\x20is\x20described\x20in\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20golang.org/x/mod/sumdb/tlog#FormatTree.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$base/lookup/$module@$version\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Returns\x20the\x20log\x20record\x20number\x20for\x20the\x20entry\x20about\x20$module\x0a\x20\x20\x20\x20\x20\x20\x20\x20at\x20$version,\x20followed\x20by\x20the\x20data\x20for\x20the\x20record\x20(that\x20is,\x0a\x20\x20\x20\x20\x20\x20\x20\x20the\x20go.sum\x20lines\x20for\x20$module\x20at\x0a\x20\x20\x20\x20\x20\x20\x20\x20$version)\x20and\x20a\x20signed,\x20encoded\x20tree\x20description\x20that\x0a\x20\x20\x20\x20\x20\x20\x20\x20contains\x20the\x20record.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$base/tile/$H/$L/$K[.p/$W]\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Returns\x20a\x20[log\x20tile](https://research.swtch.com/tlog#serving_tiles),\x0a\x20\x20\x20\x20\x20\x20\x20\x20which\x20is\x20a\x20set\x20of\x20hashes\x20that\x20make\x20up\x20a\x20section\x20of\x20the\x20log.\x20Each\x20tile\x0a\x20\x20\x20\x20\x20\x20\x20\x20is\x20defined\x20in\x20a\x20two-dimensional\x20coordinate\x20at\x20tile\x20level\x0a\x20\x20\x20\x20\x20\x20\x20\x20$L,\x20$Kth\x20from\x20the\x20left,\x20with\x20a\x20tile\x20height\x20of\x0a\x20\x20\x20\x20\x20\x20\x20\x20$H.\x20The\x20optional\x20.p/$W\x20suffix\x20indicates\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20partial\x20log\x20tile\x20with\x20only\x20$W\x20hashes.\x20Clients\x20must\x20fall\x0a\x20\x20\x20\x20\x20\x20\x20\x20back\x20to\x20fetching\x20the\x20full\x20tile\x20if\x20a\x20partial\x20tile\x20is\x20not\x20found.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$base/tile/$H/data/$K[.p/$W]\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Returns\x20the\x20record\x20data\x20for\x20the\x20leaf\x20hashes\x20in\x0a\x20\x20\x20\x20\x20\x20\x20\x20/tile/$H/0/$K[.p/$W]\x20(with\x20a\x20literal\x20data\x20path\x0a\x20\x20\x20\x20\x20\x20\x20\x20element).\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x0a

If\x20the\x20go\x20command\x20consults\x20the\x20checksum\x20database,\x20then\x20the\x20first\x0astep\x20is\x20to\x20retrieve\x20the\x20record\x20data\x20through\x20the\x20/lookup\x20endpoint.\x20If\x20the\x0amodule\x20version\x20is\x20not\x20yet\x20recorded\x20in\x20the\x20log,\x20the\x20checksum\x20database\x20will\x20try\x0ato\x20fetch\x20it\x20from\x20the\x20origin\x20server\x20before\x20replying.\x20This\x20/lookup\x20data\x0aprovides\x20the\x20sum\x20for\x20this\x20module\x20version\x20as\x20well\x20as\x20its\x20position\x20in\x20the\x20log,\x0awhich\x20informs\x20the\x20client\x20of\x20which\x20tiles\x20should\x20be\x20fetched\x20to\x20perform\x20proofs.\x0aThe\x20go\x20command\x20performs\x20\xe2\x80\x9cinclusion\xe2\x80\x9d\x20proofs\x20(that\x20a\x20specific\x20record\x20exists\x20in\x0athe\x20log)\x20and\x20\xe2\x80\x9cconsistency\xe2\x80\x9d\x20proofs\x20(that\x20the\x20tree\x20hasn\xe2\x80\x99t\x20been\x20tampered\x20with)\x0abefore\x20adding\x20new\x20go.sum\x20lines\x20to\x20the\x20main\x20module\xe2\x80\x99s\x20go.sum\x20file.\x20It's\x0aimportant\x20that\x20the\x20data\x20from\x20/lookup\x20should\x20never\x20be\x20used\x20without\x20first\x0aauthenticating\x20it\x20against\x20the\x20signed\x20tree\x20hash\x20and\x20authenticating\x20the\x20signed\x0atree\x20hash\x20against\x20the\x20client's\x20timeline\x20of\x20signed\x20tree\x20hashes.

\x0a

Signed\x20tree\x20hashes\x20and\x20new\x20tiles\x20served\x20by\x20the\x20checksum\x20database\x20are\x20stored\x0ain\x20the\x20module\x20cache,\x20so\x20the\x20go\x20command\x20only\x20needs\x20to\x20fetch\x20tiles\x20that\x20are\x0amissing.

\x0a

The\x20go\x20command\x20doesn't\x20need\x20to\x20directly\x20connect\x20to\x20the\x20checksum\x20database.\x20It\x0acan\x20request\x20module\x20sums\x20via\x20a\x20module\x20proxy\x20that\x0amirrors\x20the\x20checksum\x20database\x0aand\x20supports\x20the\x20protocol\x20above.\x20This\x20can\x20be\x20particularly\x20helpful\x20for\x20private,\x0acorporate\x20proxies\x20which\x20block\x20requests\x20outside\x20the\x20organization.

\x0a

The\x20GOSUMDB\x20environment\x20variable\x20identifies\x20the\x20name\x20of\x20checksum\x20database\x20to\x20use\x0aand\x20optionally\x20its\x20public\x20key\x20and\x20URL,\x20as\x20in:

\x0a
GOSUMDB="sum.golang.org"\x0aGOSUMDB="sum.golang.org+<publickey>"\x0aGOSUMDB="sum.golang.org+<publickey>\x20https://sum.golang.org"\x0a
\x0a

The\x20go\x20command\x20knows\x20the\x20public\x20key\x20of\x20sum.golang.org,\x20and\x20also\x20that\x20the\x0aname\x20sum.golang.google.cn\x20(available\x20inside\x20mainland\x20China)\x20connects\x20to\x20the\x0asum.golang.org\x20checksum\x20database;\x20use\x20of\x20any\x20other\x20database\x20requires\x20giving\x0athe\x20public\x20key\x20explicitly.\x20The\x20URL\x20defaults\x20to\x20https://\x20followed\x20by\x20the\x0adatabase\x20name.

\x0a

GOSUMDB\x20defaults\x20to\x20sum.golang.org,\x20the\x20Go\x20checksum\x20database\x20run\x20by\x20Google.\x0aSee\x20https://sum.golang.org/privacy\x20for\x20the\x20service's\x20privacy\x20policy.

\x0a

If\x20GOSUMDB\x20is\x20set\x20to\x20off,\x20or\x20if\x20go\x20get\x20is\x20invoked\x20with\x20the\x20-insecure\x0aflag,\x20the\x20checksum\x20database\x20is\x20not\x20consulted,\x20and\x20all\x20unrecognized\x20modules\x20are\x0aaccepted,\x20at\x20the\x20cost\x20of\x20giving\x20up\x20the\x20security\x20guarantee\x20of\x20verified\x0arepeatable\x20downloads\x20for\x20all\x20modules.\x20A\x20better\x20way\x20to\x20bypass\x20the\x20checksum\x0adatabase\x20for\x20specific\x20modules\x20is\x20to\x20use\x20the\x20GOPRIVATE\x20or\x20GONOSUMDB\x0aenvironment\x20variables.\x20See\x20Private\x20Modules\x20for\x20details.

\x0a

The\x20go\x20env\x20-w\x20command\x20can\x20be\x20used\x20to\x0aset\x20these\x20variables\x0afor\x20future\x20go\x20command\x20invocations.

\x0aPrivacy\x0aEnvironment\x20variables\x0a

Module\x20behavior\x20in\x20the\x20go\x20command\x20may\x20be\x20configured\x20using\x20the\x20environment\x0avariables\x20listed\x20below.\x20This\x20list\x20only\x20includes\x20module-related\x20environment\x0avariables.\x20See\x20go\x20help\x20environment\x20for\x20a\x20list\x0aof\x20all\x20environment\x20variables\x20recognized\x20by\x20the\x20go\x20command.

\x0a\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20Variable\x0a\x20\x20\x20\x20\x20\x20Description\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20GO111MODULE\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Controls\x20whether\x20the\x20go\x20command\x20runs\x20in\x20module-aware\x20mode\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20or\x20GOPATH\x20mode.\x20Three\x20values\x20are\x20recognized:\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20
    \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20off:\x20the\x20go\x20command\x20ignores\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20go.mod\x20files\x20and\x20runs\x20in\x20GOPATH\x20mode.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20on:\x20the\x20go\x20command\x20runs\x20in\x20module-aware\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20mode,\x20even\x20when\x20no\x20go.mod\x20file\x20is\x20present.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20auto\x20(or\x20unset):\x20the\x20go\x20command\x20runs\x20in\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module-aware\x20mode\x20if\x20a\x20go.mod\x20file\x20is\x20present\x20in\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20current\x20directory\x20or\x20any\x20parent\x20directory\x20(the\x20default\x20behavior).\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20
\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20See\x20Module-aware\x20commands\x20for\x20more\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20information.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20GOMODCACHE\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20The\x20directory\x20where\x20the\x20go\x20command\x20will\x20store\x20downloaded\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20modules\x20and\x20related\x20files.\x20See\x20Module\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20cache\x20for\x20details\x20on\x20the\x20structure\x20of\x20this\x20directory.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20If\x20GOMODCACHE\x20is\x20not\x20set,\x20it\x20defaults\x20to\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20$GOPATH/pkg/mod.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20GOINSECURE\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Comma-separated\x20list\x20of\x20glob\x20patterns\x20(in\x20the\x20syntax\x20of\x20Go's\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20path.Match)\x20of\x20module\x20path\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20prefixes\x20that\x20may\x20always\x20be\x20fetched\x20in\x20an\x20insecure\x20manner.\x20Only\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20applies\x20to\x20dependencies\x20that\x20are\x20being\x20fetched\x20directly.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Unlike\x20the\x20-insecure\x20flag\x20on\x20go\x20get,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20GOINSECURE\x20does\x20not\x20disable\x20module\x20checksum\x20database\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20validation.\x20GOPRIVATE\x20or\x20GONOSUMDB\x20may\x20be\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20used\x20to\x20achieve\x20that.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20GONOPROXY\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Comma-separated\x20list\x20of\x20glob\x20patterns\x20(in\x20the\x20syntax\x20of\x20Go's\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20path.Match)\x20of\x20module\x20path\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20prefixes\x20that\x20should\x20always\x20be\x20fetched\x20directly\x20from\x20version\x20control\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20repositories,\x20not\x20from\x20module\x20proxies.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20If\x20GONOPROXY\x20is\x20not\x20set,\x20it\x20defaults\x20to\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20GOPRIVATE.\x20See\x20Privacy.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20GONOSUMDB\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Comma-separated\x20list\x20of\x20glob\x20patterns\x20(in\x20the\x20syntax\x20of\x20Go's\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20path.Match)\x20of\x20module\x20path\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20prefixes\x20for\x20which\x20the\x20go\x20should\x20not\x20verify\x20checksums\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20using\x20the\x20checksum\x20database.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20If\x20GONOSUMDB\x20is\x20not\x20set,\x20it\x20defaults\x20to\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20GOPRIVATE.\x20See\x20Privacy.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20GOPATH\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20In\x20GOPATH\x20mode,\x20the\x20GOPATH\x20variable\x20is\x20a\x20list\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20of\x20directories\x20that\x20may\x20contain\x20Go\x20code.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20In\x20module-aware\x20mode,\x20the\x20module\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20cache\x20is\x20stored\x20in\x20the\x20pkg/mod\x20subdirectory\x20of\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20first\x20GOPATH\x20directory.\x20Module\x20source\x20code\x20outside\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20cache\x20may\x20be\x20stored\x20in\x20any\x20directory.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20If\x20GOPATH\x20is\x20not\x20set,\x20it\x20defaults\x20to\x20the\x20go\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20subdirectory\x20of\x20the\x20user's\x20home\x20directory.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20GOPRIVATE\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Comma-separated\x20list\x20of\x20glob\x20patterns\x20(in\x20the\x20syntax\x20of\x20Go's\x0a\x20\x20\x20\x20\x20\x20\x20\x20path.Match)\x20of\x20module\x20path\x0a\x20\x20\x20\x20\x20\x20\x20\x20prefixes\x20that\x20should\x20be\x20considered\x20private.\x20GOPRIVATE\x0a\x20\x20\x20\x20\x20\x20\x20\x20is\x20a\x20default\x20value\x20for\x20GONOPROXY\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20GONOSUMDB.\x20GOPRIVATE\x20itself\x20has\x20no\x20other\x0a\x20\x20\x20\x20\x20\x20\x20\x20meaning.\x20See\x20Privacy.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20GOPROXY\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20List\x20of\x20module\x20proxy\x20URLs,\x20separated\x20by\x20commas\x20(,)\x20or\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20pipes\x20(|).\x20When\x20the\x20go\x20command\x20looks\x20up\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20information\x20about\x20a\x20module,\x20it\x20contacts\x20each\x20proxy\x20in\x20the\x20list\x20in\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20sequence\x20until\x20it\x20receives\x20a\x20successful\x20response\x20or\x20a\x20terminal\x20error.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20A\x20proxy\x20may\x20respond\x20with\x20a\x20404\x20(Not\x20Found)\x20or\x20410\x20(Gone)\x20status\x20to\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20indicate\x20the\x20module\x20is\x20not\x20available\x20on\x20that\x20server.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20The\x20go\x20command's\x20error\x20fallback\x20behavior\x20is\x20determined\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20by\x20the\x20separator\x20characters\x20between\x20URLs.\x20If\x20a\x20proxy\x20URL\x20is\x20followed\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20by\x20a\x20comma,\x20the\x20go\x20command\x20falls\x20back\x20to\x20the\x20next\x20URL\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20after\x20a\x20404\x20or\x20410\x20error;\x20all\x20other\x20errors\x20are\x20considered\x20terminal.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20If\x20the\x20proxy\x20URL\x20is\x20followed\x20by\x20a\x20pipe,\x20the\x20go\x20command\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20falls\x20back\x20to\x20the\x20next\x20source\x20after\x20any\x20error,\x20including\x20non-HTTP\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20errors\x20like\x20timeouts.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20GOPROXY\x20URLs\x20may\x20have\x20the\x20schemes\x20https,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20http,\x20or\x20file.\x20If\x20a\x20URL\x20has\x20no\x20scheme,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20https\x20is\x20assumed.\x20A\x20module\x20cache\x20may\x20be\x20used\x20direclty\x20as\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20a\x20file\x20proxy:\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20
GOPROXY=file://$(go\x20env\x20GOMODCACHE)/cache/download
\x0a\x20\x20\x20\x20\x20\x20\x20\x20

Two\x20keywords\x20may\x20be\x20used\x20in\x20place\x20of\x20proxy\x20URLs:

\x0a\x20\x20\x20\x20\x20\x20\x20\x20
    \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20off:\x20disallows\x20downloading\x20modules\x20from\x20any\x20source.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20direct:\x20download\x20directly\x20from\x20version\x20control\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20repositories\x20instead\x20of\x20using\x20a\x20module\x20proxy.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20
\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20GOPROXY\x20defaults\x20to\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20https://proxy.golang.org,direct.\x20Under\x20that\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20configuration,\x20the\x20go\x20command\x20first\x20contacts\x20the\x20Go\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module\x20mirror\x20run\x20by\x20Google,\x20then\x20falls\x20back\x20to\x20a\x20direct\x20connection\x20if\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20the\x20mirror\x20does\x20not\x20have\x20the\x20module.\x20See\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20https://proxy.golang.org/privacy\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20for\x20the\x20mirror's\x20privacy\x20policy.\x20The\x20GOPRIVATE\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20GONOPROXY\x20environment\x20variables\x20may\x20be\x20set\x20to\x20prevent\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20specific\x20modules\x20from\x20being\x20downloaded\x20using\x20proxies.\x20See\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Privacy\x20for\x20information\x20on\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20private\x20proxy\x20configuration.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20See\x20Module\x20proxies\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Resolving\x20a\x20package\x20to\x20a\x20module\x20for\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20more\x20information\x20on\x20how\x20proxies\x20are\x20used.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20GOSUMDB\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Identifies\x20the\x20name\x20of\x20the\x20checksum\x20database\x20to\x20use\x20and\x20optionally\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20its\x20public\x20key\x20and\x20URL.\x20For\x20example:\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20
\x0aGOSUMDB=\"sum.golang.org\"\x0aGOSUMDB=\"sum.golang.org+<publickey>\"\x0aGOSUMDB=\"sum.golang.org+<publickey>\x20https://sum.golang.org\x0a
\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20The\x20go\x20command\x20knows\x20the\x20public\x20key\x20of\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20sum.golang.org\x20and\x20also\x20that\x20the\x20name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20sum.golang.google.cn\x20(available\x20inside\x20mainland\x20China)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20connects\x20to\x20the\x20sum.golang.org\x20database;\x20use\x20of\x20any\x20other\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20database\x20requires\x20giving\x20the\x20public\x20key\x20explicitly.\x20The\x20URL\x20defaults\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20to\x20https://\x20followed\x20by\x20the\x20database\x20name.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20GOSUMDB\x20defaults\x20to\x20sum.golang.org,\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Go\x20checksum\x20database\x20run\x20by\x20Google.\x20See\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20https://sum.golang.org/privacy\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20for\x20the\x20service's\x20privacy\x20policy.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20If\x20GOSUMDB\x20is\x20set\x20to\x20off\x20or\x20if\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20go\x20get\x20is\x20invoked\x20with\x20the\x20-insecure\x20flag,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20the\x20checksum\x20database\x20is\x20not\x20consulted,\x20and\x20all\x20unrecognized\x20modules\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20are\x20accepted,\x20at\x20the\x20cost\x20of\x20giving\x20up\x20the\x20security\x20guarantee\x20of\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20verified\x20repeatable\x20downloads\x20for\x20all\x20modules.\x20A\x20better\x20way\x20to\x20bypass\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20the\x20checksum\x20database\x20for\x20specific\x20modules\x20is\x20to\x20use\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20GOPRIVATE\x20or\x20GONOSUMDB\x20environment\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20variables.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20See\x20Authenticating\x20modules\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Privacy\x20for\x20more\x20information.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x0aGlossary\x0a

\x0abuild\x20constraint:\x20A\x20condition\x20that\x20determines\x20whether\x20a\x20Go\x20source\x20file\x20is\x0aused\x20when\x20compiling\x20a\x20package.\x20Build\x20constraints\x20may\x20be\x20expressed\x20with\x20file\x20name\x0asuffixes\x20(for\x20example,\x20foo_linux_amd64.go)\x20or\x20with\x20build\x20constraint\x20comments\x0a(for\x20example,\x20//\x20+build\x20linux,amd64).\x20See\x20Build\x0aConstraints.

\x0a

\x0abuild\x20list:\x20The\x20list\x20of\x20module\x20versions\x20that\x20will\x20be\x20used\x20for\x20a\x20build\x0acommand\x20such\x20as\x20go\x20build,\x20go\x20list,\x20or\x20go\x20test.\x20The\x20build\x20list\x20is\x0adetermined\x20from\x20the\x20main\x20module's\x20go.mod\x0afile\x20and\x20go.mod\x20files\x20in\x20transitively\x20required\x20modules\x0ausing\x20minimal\x20version\x20selection.\x20The\x20build\x0alist\x20contains\x20versions\x20for\x20all\x20modules\x20in\x20the\x20module\x0agraph,\x20not\x20just\x20those\x20relevant\x20to\x20a\x20specific\x20command.

\x0a

\x0acanonical\x20version:\x20A\x20correctly\x20formatted\x20version\x20without\x0aa\x20build\x20metadata\x20suffix\x20other\x20than\x20+incompatible.\x20For\x20example,\x20v1.2.3\x0ais\x20a\x20canonical\x20version,\x20but\x20v1.2.3+meta\x20is\x20not.

\x0a

\x0ago.mod\x20file:\x20The\x20file\x20that\x20defines\x20a\x20module's\x20path,\x20requirements,\x20and\x0aother\x20metadata.\x20Appears\x20in\x20the\x20module's\x20root\x0adirectory.\x20See\x20the\x20section\x20on\x20go.mod\x0afiles.

\x0a

\x0aimport\x20path:\x20A\x20string\x20used\x20to\x20import\x20a\x20package\x20in\x20a\x20Go\x20source\x20file.\x0aSynonymous\x20with\x20package\x20path.

\x0a

\x0amain\x20module:\x20The\x20module\x20in\x20which\x20the\x20go\x20command\x20is\x20invoked.

\x0a

\x0amajor\x20version:\x20The\x20first\x20number\x20in\x20a\x20semantic\x20version\x20(1\x20in\x20v1.2.3).\x20In\x0aa\x20release\x20with\x20incompatible\x20changes,\x20the\x20major\x20version\x20must\x20be\x20incremented,\x20and\x0athe\x20minor\x20and\x20patch\x20versions\x20must\x20be\x20set\x20to\x200.\x20Semantic\x20versions\x20with\x20major\x0aversion\x200\x20are\x20considered\x20unstable.

\x0a

\x0amajor\x20version\x20subdirectory:\x20A\x20subdirectory\x20within\x20a\x20version\x20control\x0arepository\x20matching\x20a\x20module's\x20major\x20version\x0asuffix\x20where\x20a\x20module\x20may\x20be\x20defined.\x20For\x20example,\x0athe\x20module\x20example.com/mod/v2\x20in\x20the\x20repository\x20with\x20root\x0apath\x20example.com/mod\x20may\x20be\x20defined\x20in\x20the\x0arepository\x20root\x20directory\x20or\x20the\x20major\x20version\x20subdirectory\x20v2.\x20See\x20Module\x0adirectories\x20within\x20a\x20repository.

\x0a

\x0amajor\x20version\x20suffix:\x20A\x20module\x20path\x20suffix\x20that\x20matches\x20the\x20major\x20version\x0anumber.\x20For\x20example,\x20/v2\x20in\x20example.com/mod/v2.\x20Major\x20version\x20suffixes\x20are\x0arequired\x20at\x20v2.0.0\x20and\x20later\x20and\x20are\x20not\x20allowed\x20at\x20earlier\x20versions.\x20See\x0athe\x20section\x20on\x20Major\x20version\x20suffixes.

\x0a

\x0aminimal\x20version\x20selection\x20(MVS):\x20The\x20algorithm\x20used\x20to\x20determine\x20the\x0aversions\x20of\x20all\x20modules\x20that\x20will\x20be\x20used\x20in\x20a\x20build.\x20See\x20the\x20section\x20on\x0aMinimal\x20version\x20selection\x20for\x20details.

\x0a

\x0aminor\x20version:\x20The\x20second\x20number\x20in\x20a\x20semantic\x20version\x20(2\x20in\x20v1.2.3).\x20In\x0aa\x20release\x20with\x20new,\x20backwards\x20compatible\x20functionality,\x20the\x20minor\x20version\x20must\x0abe\x20incremented,\x20and\x20the\x20patch\x20version\x20must\x20be\x20set\x20to\x200.

\x0a

\x0amodule:\x20A\x20collection\x20of\x20packages\x20that\x20are\x20released,\x20versioned,\x20and\x0adistributed\x20together.

\x0a

\x0amodule\x20cache:\x20A\x20local\x20directory\x20storing\x20downloaded\x20modules,\x20located\x20in\x0aGOPATH/pkg/mod.\x20See\x20Module\x20cache.

\x0a

\x0amodule\x20graph:\x20The\x20directed\x20graph\x20of\x20module\x20requirements,\x20rooted\x20at\x20the\x20main\x0amodule.\x20Each\x20vertex\x20in\x20the\x20graph\x20is\x20a\x20module;\x20each\x20edge\x20is\x20a\x0aversion\x20from\x20a\x20require\x20statement\x20in\x20a\x20go.mod\x20file\x20(subject\x20to\x20replace\x20and\x0aexclude\x20statements\x20in\x20the\x20main\x20module's\x20go.mod\x20file.

\x0a

\x0amodule\x20path:\x20A\x20path\x20that\x20identifies\x20a\x20module\x20and\x20acts\x20as\x20a\x20prefix\x20for\x0apackage\x20import\x20paths\x20within\x20the\x20module.\x20For\x20example,\x20"golang.org/x/net".

\x0a

\x0amodule\x20proxy:\x20A\x20web\x20server\x20that\x20implements\x20the\x20GOPROXY\x0aprotocol.\x20The\x20go\x20command\x20downloads\x20version\x20information,\x0ago.mod\x20files,\x20and\x20module\x20zip\x20files\x20from\x20module\x20proxies.

\x0a

\x0amodule\x20root\x20directory:\x20The\x20directory\x20that\x20contains\x20the\x20go.mod\x20file\x20that\x0adefines\x20a\x20module.

\x0a

\x0amodule\x20subdirectory:\x20The\x20portion\x20of\x20a\x20module\x20path\x20after\x0athe\x20repository\x20root\x20path\x20that\x20indicates\x20the\x0asubdirectory\x20where\x20the\x20module\x20is\x20defined.\x20When\x20non-empty,\x20the\x20module\x0asubdirectory\x20is\x20also\x20a\x20prefix\x20for\x20semantic\x20version\x0atags.\x20The\x20module\x20subdirectory\x20does\x20not\x20include\x20the\x0amajor\x20version\x20suffix,\x20if\x20there\x20is\x20one,\x20even\x20if\x20the\x0amodule\x20is\x20in\x20a\x20major\x20version\x20subdirectory.\x0aSee\x20Module\x20paths.

\x0a

\x0apackage:\x20A\x20collection\x20of\x20source\x20files\x20in\x20the\x20same\x20directory\x20that\x20are\x0acompiled\x20together.\x20See\x20the\x20Packages\x20section\x20in\x20the\x20Go\x0aLanguage\x20Specification.

\x0a

\x0apackage\x20path:\x20The\x20path\x20that\x20uniquely\x20identifies\x20a\x20package.\x20A\x20package\x20path\x20is\x0aa\x20module\x20path\x20joined\x20with\x20a\x20subdirectory\x20within\x20the\x20module.\x0aFor\x20example\x20"golang.org/x/net/html"\x20is\x20the\x20package\x20path\x20for\x20the\x20package\x20in\x20the\x0amodule\x20"golang.org/x/net"\x20in\x20the\x20"html"\x20subdirectory.\x20Synonym\x20of\x0aimport\x20path.

\x0a

\x0apatch\x20version:\x20The\x20third\x20number\x20in\x20a\x20semantic\x20version\x20(3\x20in\x20v1.2.3).\x20In\x0aa\x20release\x20with\x20no\x20changes\x20to\x20the\x20module's\x20public\x20interface,\x20the\x20patch\x20version\x0amust\x20be\x20incremented.

\x0a

\x0apre-release\x20version:\x20A\x20version\x20with\x20a\x20dash\x20followed\x20by\x20a\x20series\x20of\x0adot-separated\x20identifiers\x20immediately\x20following\x20the\x20patch\x20version,\x20for\x20example,\x0av1.2.3-beta4.\x20Pre-release\x20versions\x20are\x20considered\x20unstable\x20and\x20are\x20not\x0aassumed\x20to\x20be\x20compatible\x20with\x20other\x20versions.\x20A\x20pre-release\x20version\x20sorts\x20before\x0athe\x20corresponding\x20release\x20version:\x20v1.2.3-pre\x20comes\x20before\x20v1.2.3.\x20See\x20also\x0arelease\x20version.

\x0a

\x0apseudo-version:\x20A\x20version\x20that\x20encodes\x20a\x20revision\x20identifier\x20(such\x20as\x20a\x20Git\x0acommit\x20hash)\x20and\x20a\x20timestamp\x20from\x20a\x20version\x20control\x20system.\x20For\x20example,\x0av0.0.0-20191109021931-daa7c04131f5.\x20Used\x20for\x20compatibility\x20with\x20non-module\x0arepositories\x20and\x20in\x20other\x20situations\x20when\x20a\x20tagged\x0aversion\x20is\x20not\x20available.

\x0a

\x0arelease\x20version:\x20A\x20version\x20without\x20a\x20pre-release\x20suffix.\x20For\x20example,\x0av1.2.3,\x20not\x20v1.2.3-pre.\x20See\x20also\x20pre-release\x0aversion.

\x0a

\x0arepository\x20root\x20path:\x20The\x20portion\x20of\x20a\x20module\x20path\x20that\x0acorresponds\x20to\x20a\x20version\x20control\x20repository's\x20root\x20directory.\x20See\x20Module\x0apaths.

\x0a

\x0asemantic\x20version\x20tag:\x20A\x20tag\x20in\x20a\x20version\x20control\x20repository\x20that\x20maps\x20a\x0aversion\x20to\x20a\x20specific\x20revision.\x20See\x20Mapping\x20versions\x20to\x0acommits.

\x0a

\x0avendor\x20directory:\x20A\x20directory\x20named\x20vendor\x20that\x20contains\x20packages\x20from\x0aother\x20modules\x20needed\x20to\x20build\x20packages\x20in\x20the\x20main\x20module.\x20Maintained\x20with\x0ago\x20mod\x20vendor.\x20See\x20Vendoring.

\x0a

\x0aversion:\x20An\x20identifier\x20for\x20an\x20immutable\x20snapshot\x20of\x20a\x20module,\x20written\x20as\x20the\x0aletter\x20v\x20followed\x20by\x20a\x20semantic\x20version.\x20See\x20the\x20section\x20on\x0aVersions.

\x0a", + "doc/mod.html": "\x0a\x0aIntroduction\x0a

Modules\x20are\x20how\x20Go\x20manages\x20dependencies.

\x0a

This\x20document\x20is\x20a\x20detailed\x20reference\x20manual\x20for\x20Go's\x20module\x20system.\x20For\x20an\x0aintroduction\x20to\x20creating\x20Go\x20projects,\x20see\x20How\x20to\x20Write\x20Go\x0aCode.\x20For\x20information\x20on\x20using\x20modules,\x0amigrating\x20projects\x20to\x20modules,\x20and\x20other\x20topics,\x20see\x20the\x20blog\x20series\x20starting\x0awith\x20Using\x20Go\x20Modules.

\x0aModules,\x20packages,\x20and\x20versions\x0a

A\x20module\x20is\x20a\x20collection\x20of\x20packages\x20that\x20are\x20released,\x20versioned,\x0aand\x20distributed\x20together.\x20Modules\x20may\x20be\x20downloaded\x20directly\x20from\x20version\x0acontrol\x20repositories\x20or\x20from\x20module\x20proxy\x20servers.

\x0a

A\x20module\x20is\x20identified\x20by\x20a\x20module\x20path,\x20which\x20is\x20declared\x0ain\x20a\x20go.mod\x20file,\x20together\x20with\x20information\x20about\x20the\x0amodule's\x20dependencies.\x20The\x20module\x20root\x20directory\x20is\x20the\x20directory\x0athat\x20contains\x20the\x20go.mod\x20file.\x20The\x20main\x20module\x20is\x20the\x20module\x0acontaining\x20the\x20directory\x20where\x20the\x20go\x20command\x20is\x20invoked.

\x0a

Each\x20package\x20within\x20a\x20module\x20is\x20a\x20collection\x20of\x20source\x20files\x20in\x20the\x0asame\x20directory\x20that\x20are\x20compiled\x20together.\x20A\x20package\x20path\x20is\x20the\x0amodule\x20path\x20joined\x20with\x20the\x20subdirectory\x20containing\x20the\x20package\x20(relative\x20to\x20the\x0amodule\x20root).\x20For\x20example,\x20the\x20module\x20"golang.org/x/net"\x20contains\x20a\x20package\x20in\x0athe\x20directory\x20"html".\x20That\x20package's\x20path\x20is\x20"golang.org/x/net/html".

\x0aModule\x20paths\x0a

A\x20module\x20path\x20is\x20the\x20canonical\x20name\x20for\x20a\x20module,\x20declared\x20with\x20the\x0amodule\x20directive\x20in\x20the\x20module's\x20go.mod\x0afile.\x20A\x20module's\x20path\x20is\x20the\x20prefix\x20for\x20package\x20paths\x20within\x0athe\x20module.

\x0a

A\x20module\x20path\x20should\x20describe\x20both\x20what\x20the\x20module\x20does\x20and\x20where\x20to\x20find\x20it.\x0aTypically,\x20a\x20module\x20path\x20consists\x20of\x20a\x20repository\x20root\x20path,\x20a\x20directory\x20within\x0athe\x20repository\x20(usually\x20empty),\x20and\x20a\x20major\x20version\x20suffix\x20(only\x20for\x20major\x0aversion\x202\x20or\x20higher).

\x0a
    \x0a
  • The\x20repository\x20root\x20path\x20is\x20the\x20portion\x20of\x20the\x20module\x20path\x20that\x0acorresponds\x20to\x20the\x20root\x20directory\x20of\x20the\x20version\x20control\x20repository\x20where\x20the\x0amodule\x20is\x20developed.\x20Most\x20modules\x20are\x20defined\x20in\x20their\x20repository's\x20root\x0adirectory,\x20so\x20this\x20is\x20usually\x20the\x20entire\x20path.\x20For\x20example,\x0agolang.org/x/net\x20is\x20the\x20repository\x20root\x20path\x20for\x20the\x20module\x20of\x20the\x20same\x0aname.\x20See\x20Finding\x20a\x20repository\x20for\x20a\x20module\x20path\x20for\x20information\x0aon\x20how\x20the\x20go\x20command\x20locates\x20a\x20repository\x20using\x20HTTP\x20requests\x20derived\x0afrom\x20a\x20module\x20path.
  • \x0a
  • If\x20the\x20module\x20is\x20not\x20defined\x20in\x20the\x20repository's\x20root\x20directory,\x20the\x0amodule\x20subdirectory\x20is\x20the\x20part\x20of\x20the\x20module\x20path\x20that\x20names\x20the\x0adirectory,\x20not\x20including\x20the\x20major\x20version\x20suffix.\x20This\x20also\x20serves\x20as\x20a\x0aprefix\x20for\x20semantic\x20version\x20tags.\x20For\x20example,\x20the\x20module\x0agolang.org/x/tools/gopls\x20is\x20in\x20the\x20gopls\x20subdirectory\x20of\x20the\x20repository\x0awith\x20root\x20path\x20golang.org/x/tools,\x20so\x20it\x20has\x20the\x20module\x20subdirectory\x0agopls.\x20See\x20Mapping\x20versions\x20to\x20commits\x20and\x20Module\x0adirectories\x20within\x20a\x20repository.
  • \x0a
  • If\x20the\x20module\x20is\x20released\x20at\x20major\x20version\x202\x20or\x20higher,\x20the\x20module\x20path\x20must\x0aend\x20with\x20a\x20major\x20version\x20suffix\x20like\x0a/v2.\x20This\x20may\x20or\x20may\x20not\x20be\x20part\x20of\x20the\x20subdirectory\x20name.\x20For\x20example,\x20the\x0amodule\x20with\x20path\x20golang.org/x/repo/sub/v2\x20could\x20be\x20in\x20the\x20/sub\x20or\x0a/sub/v2\x20subdirectory\x20of\x20the\x20repository\x20golang.org/x/repo.
  • \x0a
\x0a

If\x20a\x20module\x20might\x20be\x20depended\x20on\x20by\x20other\x20modules,\x20these\x20rules\x20must\x20be\x20followed\x0aso\x20that\x20the\x20go\x20command\x20can\x20find\x20and\x20download\x20the\x20module.\x20There\x20are\x20also\x0aseveral\x20lexical\x20restrictions\x20on\x20characters\x20allowed\x20in\x0amodule\x20paths.

\x0aVersions\x0a

A\x20version\x20identifies\x20an\x20immutable\x20snapshot\x20of\x20a\x20module,\x20which\x20may\x20be\x0aeither\x20a\x20release\x20or\x20a\x0apre-release.\x20Each\x20version\x20starts\x20with\x20the\x20letter\x0av,\x20followed\x20by\x20a\x20semantic\x20version.\x20See\x20Semantic\x20Versioning\x0a2.0.0\x20for\x20details\x20on\x20how\x20versions\x20are\x0aformatted,\x20interpreted,\x20and\x20compared.

\x0a

To\x20summarize,\x20a\x20semantic\x20version\x20consists\x20of\x20three\x20non-negative\x20integers\x20(the\x0amajor,\x20minor,\x20and\x20patch\x20versions,\x20from\x20left\x20to\x20right)\x20separated\x20by\x20dots.\x20The\x0apatch\x20version\x20may\x20be\x20followed\x20by\x20an\x20optional\x20pre-release\x20string\x20starting\x20with\x20a\x0ahyphen.\x20The\x20pre-release\x20string\x20or\x20patch\x20version\x20may\x20be\x20followed\x20by\x20a\x20build\x0ametadata\x20string\x20starting\x20with\x20a\x20plus.\x20For\x20example,\x20v0.0.0,\x20v1.12.134,\x0av8.0.5-pre,\x20and\x20v2.0.9+meta\x20are\x20valid\x20versions.

\x0a

Each\x20part\x20of\x20a\x20version\x20indicates\x20whether\x20the\x20version\x20is\x20stable\x20and\x20whether\x20it\x20is\x0acompatible\x20with\x20previous\x20versions.

\x0a
    \x0a
  • The\x20major\x20version\x20must\x20be\x20incremented\x20and\x20the\x20minor\x0aand\x20patch\x20versions\x20must\x20be\x20set\x20to\x20zero\x20after\x20a\x20backwards\x20incompatible\x20change\x0ais\x20made\x20to\x20the\x20module's\x20public\x20interface\x20or\x20documented\x20functionality,\x20for\x0aexample,\x20after\x20a\x20package\x20is\x20removed.
  • \x0a
  • The\x20minor\x20version\x20must\x20be\x20incremented\x20and\x20the\x20patch\x0aversion\x20set\x20to\x20zero\x20after\x20a\x20backwards\x20compatible\x20change,\x20for\x20example,\x20after\x20a\x0anew\x20function\x20is\x20added.
  • \x0a
  • The\x20patch\x20version\x20must\x20be\x20incremented\x20after\x20a\x20change\x0athat\x20does\x20not\x20affect\x20the\x20module's\x20public\x20interface,\x20such\x20as\x20a\x20bug\x20fix\x20or\x0aoptimization.
  • \x0a
  • The\x20pre-release\x20suffix\x20indicates\x20a\x20version\x20is\x20a\x0apre-release.\x20Pre-release\x20versions\x20sort\x20before\x0athe\x20corresponding\x20release\x20versions.\x20For\x20example,\x20v1.2.3-pre\x20comes\x20before\x0av1.2.3.
  • \x0a
  • The\x20build\x20metadata\x20suffix\x20is\x20ignored\x20for\x20the\x20purpose\x20of\x20comparing\x20versions.\x0aTags\x20with\x20build\x20metadata\x20are\x20ignored\x20in\x20version\x20control\x20repositories,\x20but\x0abuild\x20metadata\x20is\x20preserved\x20in\x20versions\x20specified\x20in\x20go.mod\x20files.\x20The\x0asuffix\x20+incompatible\x20denotes\x20a\x20version\x20released\x20before\x20migrating\x20to\x20modules\x0aversion\x20major\x20version\x202\x20or\x20later\x20(see\x20Compatibility\x20with\x20non-module\x0arepositories.
  • \x0a
\x0a

A\x20version\x20is\x20considered\x20unstable\x20if\x20its\x20major\x20version\x20is\x200\x20or\x20it\x20has\x20a\x0apre-release\x20suffix.\x20Unstable\x20versions\x20are\x20not\x20subject\x20to\x20compatibility\x0arequirements.\x20For\x20example,\x20v0.2.0\x20may\x20not\x20be\x20compatible\x20with\x20v0.1.0,\x20and\x0av1.5.0-beta\x20may\x20not\x20be\x20compatible\x20with\x20v1.5.0.

\x0a

Go\x20may\x20access\x20modules\x20in\x20version\x20control\x20systems\x20using\x20tags,\x20branches,\x20or\x0arevisions\x20that\x20don't\x20follow\x20these\x20conventions.\x20However,\x20within\x20the\x20main\x20module,\x0athe\x20go\x20command\x20will\x20automatically\x20convert\x20revision\x20names\x20that\x20don't\x20follow\x0athis\x20standard\x20into\x20canonical\x20versions.\x20The\x20go\x20command\x20will\x20also\x20remove\x20build\x0ametadata\x20suffixes\x20(except\x20for\x20+incompatible)\x20as\x20part\x20of\x20this\x20process.\x20This\x20may\x0aresult\x20in\x20a\x20pseudo-version,\x20a\x20pre-release\x20version\x20that\x0aencodes\x20a\x20revision\x20identifier\x20(such\x20as\x20a\x20Git\x20commit\x20hash)\x20and\x20a\x20timestamp\x20from\x20a\x0aversion\x20control\x20system.\x20For\x20example,\x20the\x20command\x20go\x20get\x20-d\x20golang.org/x/net@daa7c041\x20will\x20convert\x20the\x20commit\x20hash\x20daa7c041\x20into\x20the\x0apseudo-version\x20v0.0.0-20191109021931-daa7c04131f5.\x20Canonical\x20versions\x20are\x0arequired\x20outside\x20the\x20main\x20module,\x20and\x20the\x20go\x20command\x20will\x20report\x20an\x20error\x20if\x20a\x0anon-canonical\x20version\x20like\x20master\x20appears\x20in\x20a\x20go.mod\x20file.

\x0aPseudo-versions\x0a

A\x20pseudo-version\x20is\x20a\x20specially\x20formatted\x0apre-release\x20version\x20that\x20encodes\x0ainformation\x20about\x20a\x20specific\x20revision\x20in\x20a\x20version\x20control\x20repository.\x20For\x0aexample,\x20v0.0.0-20191109021931-daa7c04131f5\x20is\x20a\x20pseudo-version.

\x0a

Pseudo-versions\x20may\x20refer\x20to\x20revisions\x20for\x20which\x20no\x20semantic\x20version\x0atags\x20are\x20available.\x20They\x20may\x20be\x20used\x20to\x20test\x0acommits\x20before\x20creating\x20version\x20tags,\x20for\x20example,\x20on\x20a\x20development\x20branch.

\x0a

Each\x20pseudo-version\x20has\x20three\x20parts:

\x0a
    \x0a
  • A\x20base\x20version\x20prefix\x20(vX.0.0\x20or\x20vX.Y.Z-0),\x20which\x20is\x20either\x20derived\x20from\x20a\x0asemantic\x20version\x20tag\x20that\x20precedes\x20the\x20revision\x20or\x20vX.0.0\x20if\x20there\x20is\x20no\x0asuch\x20tag.
  • \x0a
  • A\x20timestamp\x20(yymmddhhmmss),\x20which\x20is\x20the\x20UTC\x20time\x20the\x20revision\x20was\x20created.\x0aIn\x20Git,\x20this\x20is\x20the\x20commit\x20time,\x20not\x20the\x20author\x20time.
  • \x0a
  • A\x20revision\x20identifier\x20(abcdefabcdef),\x20which\x20is\x20a\x2012-character\x20prefix\x20of\x20the\x0acommit\x20hash,\x20or\x20in\x20Subversion,\x20a\x20zero-padded\x20revision\x20number.
  • \x0a
\x0a

Each\x20pseudo-version\x20may\x20be\x20in\x20one\x20of\x20three\x20forms,\x20depending\x20on\x20the\x20base\x20version.\x0aThese\x20forms\x20ensure\x20that\x20a\x20pseudo-version\x20compares\x20higher\x20than\x20its\x20base\x20version,\x0abut\x20lower\x20than\x20the\x20next\x20tagged\x20version.

\x0a
    \x0a
  • vX.0.0-yyyymmddhhmmss-abcdefabcdef\x20is\x20used\x20when\x20there\x20is\x20no\x20known\x20base\x0aversion.\x20As\x20with\x20all\x20versions,\x20the\x20major\x20version\x20X\x20must\x20match\x20the\x20module's\x0amajor\x20version\x20suffix.
  • \x0a
  • vX.Y.Z-pre.0.yyyymmddhhmmss-abcdefabcdef\x20is\x20used\x20when\x20the\x20base\x20version\x20is\x0aa\x20pre-release\x20version\x20like\x20vX.Y.Z-pre.
  • \x0a
  • vX.Y.(Z+1)-0.yyyymmddhhmmss-abcdefabcdef\x20is\x20used\x20when\x20the\x20base\x20version\x20is\x0aa\x20release\x20version\x20like\x20vX.Y.Z.\x20For\x20example,\x20if\x20the\x20base\x20version\x20is\x0av1.2.3,\x20a\x20pseudo-version\x20might\x20be\x20v1.2.4-0.20191109021931-daa7c04131f5.
  • \x0a
\x0a

More\x20than\x20one\x20pseudo-version\x20may\x20refer\x20to\x20the\x20same\x20commit\x20by\x20using\x20different\x0abase\x20versions.\x20This\x20happens\x20naturally\x20when\x20a\x20lower\x20version\x20is\x20tagged\x20after\x20a\x0apseudo-version\x20is\x20written.

\x0a

These\x20forms\x20give\x20pseudo-versions\x20two\x20useful\x20properties:

\x0a
    \x0a
  • Pseudo-versions\x20with\x20known\x20base\x20versions\x20sort\x20higher\x20than\x20those\x20versions\x20but\x0alower\x20than\x20other\x20pre-release\x20for\x20later\x20versions.
  • \x0a
  • Pseudo-versions\x20with\x20the\x20same\x20base\x20version\x20prefix\x20sort\x20chronologically.
  • \x0a
\x0a

The\x20go\x20command\x20performs\x20several\x20checks\x20to\x20ensure\x20that\x20module\x20authors\x20have\x0acontrol\x20over\x20how\x20pseudo-versions\x20are\x20compared\x20with\x20other\x20versions\x20and\x20that\x0apseudo-versions\x20refer\x20to\x20revisions\x20that\x20are\x20actually\x20part\x20of\x20a\x20module's\x0acommit\x20history.

\x0a
    \x0a
  • If\x20a\x20base\x20version\x20is\x20specified,\x20there\x20must\x20be\x20a\x20corresponding\x20semantic\x20version\x0atag\x20that\x20is\x20an\x20ancestor\x20of\x20the\x20revision\x20described\x20by\x20the\x20pseudo-version.\x20This\x0aprevents\x20developers\x20from\x20bypassing\x20minimal\x20version\x0aselection\x20using\x20a\x20pseudo-version\x20that\x0acompares\x20higher\x20than\x20all\x20tagged\x20versions\x20like\x0av1.999.999-99999999999999-daa7c04131f5.
  • \x0a
  • The\x20timestamp\x20must\x20match\x20the\x20revision's\x20timestamp.\x20This\x20prevents\x20attackers\x0afrom\x20flooding\x20module\x20proxies\x20with\x20an\x20unbounded\x20number\x0aof\x20otherwise\x20identical\x20pseudo-versions.\x20This\x20also\x20prevents\x20module\x20consumers\x0afrom\x20changing\x20the\x20relative\x20ordering\x20of\x20versions.
  • \x0a
  • The\x20revision\x20must\x20be\x20an\x20ancestor\x20of\x20one\x20of\x20the\x20module\x20repository's\x20branches\x20or\x0atags.\x20This\x20prevents\x20attackers\x20from\x20referring\x20to\x20unapproved\x20changes\x20or\x20pull\x0arequests.
  • \x0a
\x0a

Pseudo-versions\x20never\x20need\x20to\x20be\x20typed\x20by\x20hand.\x20Many\x20commands\x20accept\x0aa\x20commit\x20hash\x20or\x20a\x20branch\x20name\x20and\x20will\x20translate\x20it\x20into\x20a\x20pseudo-version\x0a(or\x20tagged\x20version\x20if\x20available)\x20automatically.\x20For\x20example:

\x0a
go\x20get\x20-d\x20example.com/mod@master\x0ago\x20list\x20-m\x20-json\x20example.com/mod@abcd1234\x0a
\x0aMajor\x20version\x20suffixes\x0a

Starting\x20with\x20major\x20version\x202,\x20module\x20paths\x20must\x20have\x20a\x20major\x20version\x0asuffix\x20like\x20/v2\x20that\x20matches\x20the\x20major\x20version.\x20For\x20example,\x20if\x20a\x20module\x0ahas\x20the\x20path\x20example.com/mod\x20at\x20v1.0.0,\x20it\x20must\x20have\x20the\x20path\x0aexample.com/mod/v2\x20at\x20version\x20v2.0.0.

\x0a

Major\x20version\x20suffixes\x20implement\x20the\x20import\x20compatibility\x0arule:

\x0a
\x0a

If\x20an\x20old\x20package\x20and\x20a\x20new\x20package\x20have\x20the\x20same\x20import\x20path,\x0athe\x20new\x20package\x20must\x20be\x20backwards\x20compatible\x20with\x20the\x20old\x20package.

\x0a
\x0a

By\x20definition,\x20packages\x20in\x20a\x20new\x20major\x20version\x20of\x20a\x20module\x20are\x20not\x20backwards\x0acompatible\x20with\x20the\x20corresponding\x20packages\x20in\x20the\x20previous\x20major\x20version.\x0aConsequently,\x20starting\x20with\x20v2,\x20packages\x20need\x20new\x20import\x20paths.\x20This\x20is\x0aaccomplished\x20by\x20adding\x20a\x20major\x20version\x20suffix\x20to\x20the\x20module\x20path.\x20Since\x20the\x0amodule\x20path\x20is\x20a\x20prefix\x20of\x20the\x20import\x20path\x20for\x20each\x20package\x20within\x20the\x20module,\x0aadding\x20the\x20major\x20version\x20suffix\x20to\x20the\x20module\x20path\x20provides\x20a\x20distinct\x20import\x0apath\x20for\x20each\x20incompatible\x20version.

\x0a

Major\x20version\x20suffixes\x20are\x20not\x20allowed\x20at\x20major\x20versions\x20v0\x20or\x20v1.\x20There\x20is\x0ano\x20need\x20to\x20change\x20the\x20module\x20path\x20between\x20v0\x20and\x20v1\x20because\x20v0\x20versions\x0aare\x20unstable\x20and\x20have\x20no\x20compatibility\x20guarantee.\x20Additionally,\x20for\x20most\x0amodules,\x20v1\x20is\x20backwards\x20compatible\x20with\x20the\x20last\x20v0\x20version;\x20a\x20v1\x20version\x0aacts\x20as\x20a\x20commitment\x20to\x20compatibility,\x20rather\x20than\x20an\x20indication\x20of\x0aincompatible\x20changes\x20compared\x20with\x20v0.

\x0a

As\x20a\x20special\x20case,\x20modules\x20paths\x20starting\x20with\x20gopkg.in/\x20must\x20always\x20have\x20a\x0amajor\x20version\x20suffix,\x20even\x20at\x20v0\x20and\x20v1.\x20The\x20suffix\x20must\x20start\x20with\x20a\x20dot\x0arather\x20than\x20a\x20slash\x20(for\x20example,\x20gopkg.in/yaml.v2).

\x0a

Major\x20version\x20suffixes\x20let\x20multiple\x20major\x20versions\x20of\x20a\x20module\x20coexist\x20in\x20the\x0asame\x20build.\x20This\x20may\x20be\x20necessary\x20due\x20to\x20a\x20diamond\x20dependency\x0aproblem.\x20Ordinarily,\x20if\x0aa\x20module\x20is\x20required\x20at\x20two\x20different\x20versions\x20by\x20transitive\x20dependencies,\x20the\x0ahigher\x20version\x20will\x20be\x20used.\x20However,\x20if\x20the\x20two\x20versions\x20are\x20incompatible,\x0aneither\x20version\x20will\x20satisfy\x20all\x20clients.\x20Since\x20incompatible\x20versions\x20must\x20have\x0adifferent\x20major\x20version\x20numbers,\x20they\x20must\x20also\x20have\x20different\x20module\x20paths\x20due\x0ato\x20major\x20version\x20suffixes.\x20This\x20resolves\x20the\x20conflict:\x20modules\x20with\x20distinct\x0asuffixes\x20are\x20treated\x20as\x20separate\x20modules,\x20and\x20their\x20packages\xe2\x80\x94even\x20packages\x20in\x0asame\x20subdirectory\x20relative\x20to\x20their\x20module\x20roots\xe2\x80\x94are\x20distinct.

\x0a

Many\x20Go\x20projects\x20released\x20versions\x20at\x20v2\x20or\x20higher\x20without\x20using\x20a\x20major\x0aversion\x20suffix\x20before\x20migrating\x20to\x20modules\x20(perhaps\x20before\x20modules\x20were\x20even\x0aintroduced).\x20These\x20versions\x20are\x20annotated\x20with\x20a\x20+incompatible\x20build\x20tag\x20(for\x0aexample,\x20v2.0.0+incompatible).\x20See\x20Compatibility\x20with\x20non-module\x0arepositories\x20for\x20more\x20information.

\x0aResolving\x20a\x20package\x20to\x20a\x20module\x0a

When\x20the\x20go\x20command\x20loads\x20a\x20package\x20using\x20a\x20package\x0apath,\x20it\x20needs\x20to\x20determine\x20which\x20module\x20provides\x20the\x0apackage.

\x0a

The\x20go\x20command\x20starts\x20by\x20searching\x20the\x20build\x20list\x20for\x0amodules\x20with\x20paths\x20that\x20are\x20prefixes\x20of\x20the\x20package\x20path.\x20For\x20example,\x20if\x20the\x0apackage\x20example.com/a/b\x20is\x20imported,\x20and\x20the\x20module\x20example.com/a\x20is\x20in\x20the\x0abuild\x20list,\x20the\x20go\x20command\x20will\x20check\x20whether\x20example.com/a\x20contains\x20the\x0apackage,\x20in\x20the\x20directory\x20b.\x20At\x20least\x20one\x20file\x20with\x20the\x20.go\x20extension\x20must\x0abe\x20present\x20in\x20a\x20directory\x20for\x20it\x20to\x20be\x20considered\x20a\x20package.\x20Build\x0aconstraints\x20are\x20not\x20applied\x20for\x20this\x0apurpose.\x20If\x20exactly\x20one\x20module\x20in\x20the\x20build\x20list\x20provides\x20the\x20package,\x20that\x0amodule\x20is\x20used.\x20If\x20two\x20or\x20more\x20modules\x20provide\x20the\x20package,\x20an\x20error\x20is\x0areported.\x20If\x20no\x20modules\x20provide\x20the\x20package,\x20the\x20go\x20command\x20will\x20attempt\x20to\x0afind\x20a\x20new\x20module\x20(unless\x20the\x20flags\x20-mod=readonly\x20or\x20-mod=vendor\x20are\x20used,\x0ain\x20which\x20case,\x20an\x20error\x20is\x20reported).

\x0a\x0a

When\x20the\x20go\x20command\x20looks\x20up\x20a\x20new\x20module\x20for\x20a\x20package\x20path,\x20it\x20checks\x20the\x0aGOPROXY\x20environment\x20variable,\x20which\x20is\x20a\x20comma-separated\x20list\x20of\x20proxy\x20URLs\x20or\x0athe\x20keywords\x20direct\x20or\x20off.\x20A\x20proxy\x20URL\x20indicates\x20the\x20go\x20command\x20should\x0acontact\x20a\x20module\x20proxy\x20using\x20the\x20GOPROXY\x0aprotocol.\x20direct\x20indicates\x20that\x20the\x20go\x20command\x20should\x0acommunicate\x20with\x20a\x20version\x20control\x20system.\x20off\x20indicates\x20that\x20no\x0acommunication\x20should\x20be\x20attempted.\x20The\x20GOPRIVATE\x20and\x20GONOPROXY\x20environment\x0avariables\x20can\x20also\x20be\x20used\x20to\x20control\x20this\x20behavior.

\x0a

For\x20each\x20entry\x20in\x20the\x20GOPROXY\x20list,\x20the\x20go\x20command\x20requests\x20the\x20latest\x0aversion\x20of\x20each\x20module\x20path\x20that\x20might\x20provide\x20the\x20package\x20(that\x20is,\x20each\x20prefix\x0aof\x20the\x20package\x20path).\x20For\x20each\x20successfully\x20requested\x20module\x20path,\x20the\x20go\x0acommand\x20will\x20download\x20the\x20module\x20at\x20the\x20latest\x20version\x20and\x20check\x20whether\x20the\x0amodule\x20contains\x20the\x20requested\x20package.\x20If\x20one\x20or\x20more\x20modules\x20contain\x20the\x0arequested\x20package,\x20the\x20module\x20with\x20the\x20longest\x20path\x20is\x20used.\x20If\x20one\x20or\x20more\x0amodules\x20are\x20found\x20but\x20none\x20contain\x20the\x20requested\x20package,\x20an\x20error\x20is\x0areported.\x20If\x20no\x20modules\x20are\x20found,\x20the\x20go\x20command\x20tries\x20the\x20next\x20entry\x20in\x20the\x0aGOPROXY\x20list.\x20If\x20no\x20entries\x20are\x20left,\x20an\x20error\x20is\x20reported.

\x0a

For\x20example,\x20suppose\x20the\x20go\x20command\x20is\x20looking\x20for\x20a\x20module\x20that\x20provides\x20the\x0apackage\x20golang.org/x/net/html,\x20and\x20GOPROXY\x20is\x20set\x20to\x0ahttps://corp.example.com,https://proxy.golang.org.\x20The\x20go\x20command\x20may\x20make\x0athe\x20following\x20requests:

\x0a
    \x0a
  • To\x20https://corp.example.com/\x20(in\x20parallel):\x0a
      \x0a
    • Request\x20for\x20latest\x20version\x20of\x20golang.org/x/net/html
    • \x0a
    • Request\x20for\x20latest\x20version\x20of\x20golang.org/x/net
    • \x0a
    • Request\x20for\x20latest\x20version\x20of\x20golang.org/x
    • \x0a
    • Request\x20for\x20latest\x20version\x20of\x20golang.org
    • \x0a
    \x0a
  • \x0a
  • To\x20https://proxy.golang.org/,\x20if\x20all\x20requests\x20to\x20https://corp.example.com/\x0ahave\x20failed\x20with\x20404\x20or\x20410:\x0a
      \x0a
    • Request\x20for\x20latest\x20version\x20of\x20golang.org/x/net/html
    • \x0a
    • Request\x20for\x20latest\x20version\x20of\x20golang.org/x/net
    • \x0a
    • Request\x20for\x20latest\x20version\x20of\x20golang.org/x
    • \x0a
    • Request\x20for\x20latest\x20version\x20of\x20golang.org
    • \x0a
    \x0a
  • \x0a
\x0a

After\x20a\x20suitable\x20module\x20has\x20been\x20found,\x20the\x20go\x20command\x20will\x20add\x20a\x20new\x0arequirement\x20with\x20the\x20new\x20module's\x20path\x20and\x20version\x20to\x20the\x0amain\x20module's\x20go.mod\x20file.\x20This\x20ensures\x20that\x20when\x20the\x20same\x20package\x20is\x20loaded\x0ain\x20the\x20future,\x20the\x20same\x20module\x20will\x20be\x20used\x20at\x20the\x20same\x20version.\x20If\x20the\x20resolved\x0apackage\x20is\x20not\x20imported\x20by\x20a\x20package\x20in\x20the\x20main\x20module,\x20the\x20new\x20requirement\x0awill\x20have\x20an\x20//\x20indirect\x20comment.

\x0ago.mod\x20files\x0a

A\x20module\x20is\x20defined\x20by\x20a\x20UTF-8\x20encoded\x20text\x20file\x20named\x20go.mod\x20in\x20its\x20root\x0adirectory.\x20The\x20go.mod\x20file\x20is\x20line-oriented.\x20Each\x20line\x20holds\x20a\x20single\x0adirective,\x20made\x20up\x20of\x20a\x20keyword\x20followed\x20by\x20arguments.\x20For\x20example:

\x0a
module\x20example.com/my/thing\x0a\x0ago\x201.12\x0a\x0arequire\x20example.com/other/thing\x20v1.0.2\x0arequire\x20example.com/new/thing/v2\x20v2.3.4\x0aexclude\x20example.com/old/thing\x20v1.2.3\x0areplace\x20example.com/bad/thing\x20v1.4.5\x20=>\x20example.com/good/thing\x20v1.4.5\x0a
\x0a

The\x20leading\x20keyword\x20can\x20be\x20factored\x20out\x20of\x20adjacent\x20lines\x20to\x20create\x20a\x20block,\x0alike\x20in\x20Go\x20imports.

\x0a
require\x20(\x0a\x20\x20\x20\x20example.com/new/thing/v2\x20v2.3.4\x0a\x20\x20\x20\x20example.com/old/thing\x20v1.2.3\x0a)\x0a
\x0a

The\x20go.mod\x20file\x20is\x20designed\x20to\x20be\x20human\x20readable\x20and\x20machine\x20writable.\x20The\x0ago\x20command\x20provides\x20several\x20subcommands\x20that\x20change\x20go.mod\x20files.\x20For\x0aexample,\x20go\x20get\x20can\x20upgrade\x20or\x20downgrade\x20specific\x20dependencies.\x0aCommands\x20that\x20load\x20the\x20module\x20graph\x20will\x20automatically\x20update\x0ago.mod\x20when\x20needed.\x20go\x20mod\x20edit\x20can\x20perform\x20low-level\x20edits.\x0aThe\x0agolang.org/x/mod/modfile\x0apackage\x20can\x20be\x20used\x20by\x20Go\x20programs\x20to\x20make\x20the\x20same\x20changes\x20programmatically.

\x0aLexical\x20elements\x0a

When\x20a\x20go.mod\x20file\x20is\x20parsed,\x20its\x20content\x20is\x20broken\x20into\x20a\x20sequence\x20of\x20tokens.\x0aThere\x20are\x20several\x20kinds\x20of\x20tokens:\x20whitespace,\x20comments,\x20punctuation,\x0akeywords,\x20identifiers,\x20and\x20strings.

\x0a

White\x20space\x20consists\x20of\x20spaces\x20(U+0020),\x20tabs\x20(U+0009),\x20carriage\x20returns\x0a(U+000D),\x20and\x20newlines\x20(U+000A).\x20White\x20space\x20characters\x20other\x20than\x20newlines\x20have\x0ano\x20effect\x20except\x20to\x20separate\x20tokens\x20that\x20would\x20otherwise\x20be\x20combined.\x20Newlines\x0aare\x20significant\x20tokens.

\x0a

Comments\x20start\x20with\x20//\x20and\x20run\x20to\x20the\x20end\x20of\x20a\x20line.\x20/*\x20*/\x20comments\x20are\x0anot\x20allowed.

\x0a

Punctuation\x20tokens\x20include\x20(,\x20),\x20and\x20=>.

\x0a

Keywords\x20distinguish\x20different\x20kinds\x20of\x20directives\x20in\x20a\x20go.mod\x20file.\x20Allowed\x0akeywords\x20are\x20module,\x20go,\x20require,\x20replace,\x20and\x20exclude.

\x0a

Identifiers\x20are\x20sequences\x20of\x20non-whitespace\x20characters,\x20such\x20as\x20module\x20paths\x0aor\x20semantic\x20versions.

\x0a

Strings\x20are\x20quoted\x20sequences\x20of\x20characters.\x20There\x20are\x20two\x20kinds\x20of\x20strings:\x0ainterpreted\x20strings\x20beginning\x20and\x20ending\x20with\x20quotation\x20marks\x20(",\x20U+0022)\x20and\x0araw\x20strings\x20beginning\x20and\x20ending\x20with\x20grave\x20accents\x20(<,\x0aU+0060).\x20Interpreted\x20strings\x20may\x20contain\x20escape\x20sequences\x20consisting\x20of\x20a\x0abackslash\x20(\\,\x20U+005C)\x20followed\x20by\x20another\x20character.\x20An\x20escaped\x20quotation\x0amark\x20(\\")\x20does\x20not\x20terminate\x20an\x20interpreted\x20string.\x20The\x20unquoted\x20value\x0aof\x20an\x20interpreted\x20string\x20is\x20the\x20sequence\x20of\x20characters\x20between\x20quotation\x0amarks\x20with\x20each\x20escape\x20sequence\x20replaced\x20by\x20the\x20character\x20following\x20the\x0abackslash\x20(for\x20example,\x20\\"\x20is\x20replaced\x20by\x20",\x20\\n\x20is\x20replaced\x20by\x20n).\x0aIn\x20contrast,\x20the\x20unquoted\x20value\x20of\x20a\x20raw\x20string\x20is\x20simply\x20the\x20sequence\x20of\x0acharacters\x20between\x20grave\x20accents;\x20backslashes\x20have\x20no\x20special\x20meaning\x20within\x0araw\x20strings.

\x0a

Identifiers\x20and\x20strings\x20are\x20interchangeable\x20in\x20the\x20go.mod\x20grammar.

\x0aModule\x20paths\x20and\x20versions\x0a

Most\x20identifiers\x20and\x20strings\x20in\x20a\x20go.mod\x20file\x20are\x20either\x20module\x20paths\x20or\x0aversions.

\x0a

A\x20module\x20path\x20must\x20satisfy\x20the\x20following\x20requirements:

\x0a
    \x0a
  • The\x20path\x20must\x20consist\x20of\x20one\x20or\x20more\x20path\x20elements\x20separated\x20by\x20slashes\x0a(/,\x20U+002F).\x20It\x20must\x20not\x20begin\x20or\x20end\x20with\x20a\x20slash.
  • \x0a
  • Each\x20path\x20element\x20is\x20a\x20non-empty\x20string\x20made\x20of\x20up\x20ASCII\x20letters,\x20ASCII\x0adigits,\x20and\x20limited\x20ASCII\x20punctuation\x20(+,\x20-,\x20.,\x20_,\x20and\x20~).
  • \x0a
  • A\x20path\x20element\x20may\x20not\x20begin\x20or\x20end\x20with\x20a\x20dot\x20(.,\x20U+002E).
  • \x0a
  • The\x20element\x20prefix\x20up\x20to\x20the\x20first\x20dot\x20must\x20not\x20be\x20a\x20reserved\x20file\x20name\x20on\x0aWindows,\x20regardless\x20of\x20case\x20(CON,\x20com1,\x20NuL,\x20and\x20so\x20on).
  • \x0a
\x0a

If\x20the\x20module\x20path\x20appears\x20in\x20a\x20require\x20directive\x20and\x20is\x20not\x20replaced,\x20or\x0aif\x20the\x20module\x20paths\x20appears\x20on\x20the\x20right\x20side\x20of\x20a\x20replace\x20directive,\x0athe\x20go\x20command\x20may\x20need\x20to\x20download\x20modules\x20with\x20that\x20path,\x20and\x20some\x0aadditional\x20requirements\x20must\x20be\x20satisfied.

\x0a
    \x0a
  • The\x20leading\x20path\x20element\x20(up\x20to\x20the\x20first\x20slash,\x20if\x20any),\x20by\x20convention\x20a\x0adomain\x20name,\x20must\x20contain\x20only\x20lower-case\x20ASCII\x20letters,\x20ASCII\x20digits,\x20dots\x0a(.,\x20U+002E),\x20and\x20dashes\x20(-,\x20U+002D);\x20it\x20must\x20contain\x20at\x20least\x20one\x20dot\x20and\x0acannot\x20start\x20with\x20a\x20dash.
  • \x0a
  • For\x20a\x20final\x20path\x20element\x20of\x20the\x20form\x20/vN\x20where\x20N\x20looks\x20numeric\x20(ASCII\x0adigits\x20and\x20dots),\x20N\x20must\x20not\x20begin\x20with\x20a\x20leading\x20zero,\x20must\x20not\x20be\x20/v1,\x0aand\x20must\x20not\x20contain\x20any\x20dots.\x0a
      \x0a
    • For\x20paths\x20beginning\x20with\x20gopkg.in/,\x20this\x20requirement\x20is\x20replaced\x20by\x20a\x0arequirement\x20that\x20the\x20path\x20follow\x20the\x20gopkg.in\x20service's\x0aconventions.
    • \x0a
    \x0a
  • \x0a
\x0a

Versions\x20in\x20go.mod\x20files\x20may\x20be\x20canonical\x20or\x0anon-canonical.

\x0a

A\x20canonical\x20version\x20starts\x20with\x20the\x20letter\x20v,\x20followed\x20by\x20a\x20semantic\x20version\x0afollowing\x20the\x20Semantic\x20Versioning\x202.0.0\x0aspecification.\x20See\x20Versions\x20for\x20more\x20information.

\x0a

Most\x20other\x20identifiers\x20and\x20strings\x20may\x20be\x20used\x20as\x20non-canonical\x20versions,\x20though\x0athere\x20are\x20some\x20restrictions\x20to\x20avoid\x20problems\x20with\x20file\x20systems,\x20repositories,\x0aand\x20module\x20proxies.\x20Non-canonical\x20versions\x20are\x20only\x0aallowed\x20in\x20the\x20main\x20module's\x20go.mod\x20file.\x20The\x20go\x20command\x20will\x20attempt\x20to\x0areplace\x20each\x20non-canonical\x20version\x20with\x20an\x20equivalent\x20canonical\x20version\x20when\x20it\x0aautomatically\x20updates\x20the\x20go.mod\x20file.

\x0a

In\x20places\x20where\x20a\x20module\x20path\x20is\x20associated\x20with\x20a\x20verison\x20(as\x20in\x20require,\x0areplace,\x20and\x20exclude\x20directives),\x20the\x20final\x20path\x20element\x20must\x20be\x20consistent\x0awith\x20the\x20version.\x20See\x20Major\x20version\x20suffixes.

\x0aGrammar\x0a

go.mod\x20syntax\x20is\x20specified\x20below\x20using\x20Extended\x20Backus-Naur\x20Form\x20(EBNF).\x0aSee\x20the\x20Notation\x20section\x20in\x20the\x20Go\x20Language\x20Specificiation\x0afor\x20details\x20on\x20EBNF\x20syntax.

\x0a
GoMod\x20=\x20{\x20Directive\x20}\x20.\x0aDirective\x20=\x20ModuleDirective\x20|\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20GoDirective\x20|\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20RequireDirective\x20|\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ExcludeDirective\x20|\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20ReplaceDirective\x20.\x0a
\x0a

Newlines,\x20identifiers,\x20and\x20strings\x20are\x20denoted\x20with\x20newline,\x20ident,\x20and\x0astring,\x20respectively.

\x0a

Module\x20paths\x20and\x20versions\x20are\x20denoted\x20with\x20ModulePath\x20and\x20Version.

\x0a
ModulePath\x20=\x20ident\x20|\x20string\x20.\x20/*\x20see\x20restrictions\x20above\x20*/\x0aVersion\x20=\x20ident\x20|\x20string\x20.\x20\x20\x20\x20/*\x20see\x20restrictions\x20above\x20*/\x0a
\x0amodule\x20directive\x0a

A\x20module\x20directive\x20defines\x20the\x20main\x20module's\x20path.\x20A\x0ago.mod\x20file\x20must\x20contain\x20exactly\x20one\x20module\x20directive.

\x0a
ModuleDirective\x20=\x20"module"\x20(\x20ModulePath\x20|\x20"("\x20newline\x20ModulePath\x20newline\x20")"\x20newline\x20.\x0a
\x0a

Example:

\x0a
module\x20golang.org/x/net\x0a
\x0ago\x20directive\x0a

A\x20go\x20directive\x20sets\x20the\x20expected\x20language\x20version\x20for\x20the\x20module.\x20The\x0aversion\x20must\x20be\x20a\x20valid\x20Go\x20release\x20version:\x20a\x20positive\x20integer\x20followed\x20by\x20a\x20dot\x0aand\x20a\x20non-negative\x20integer\x20(for\x20example,\x201.9,\x201.14).

\x0a

The\x20language\x20version\x20determines\x20which\x20language\x20features\x20are\x20available\x20when\x0acompiling\x20packages\x20in\x20the\x20module.\x20Language\x20features\x20present\x20in\x20that\x20version\x0awill\x20be\x20available\x20for\x20use.\x20Language\x20features\x20removed\x20in\x20earlier\x20versions,\x0aor\x20added\x20in\x20later\x20versions,\x20will\x20not\x20be\x20available.\x20The\x20language\x20version\x20does\x20not\x0aaffect\x20build\x20tags,\x20which\x20are\x20determined\x20by\x20the\x20Go\x20release\x20being\x20used.

\x0a

The\x20language\x20version\x20is\x20also\x20used\x20to\x20enable\x20features\x20in\x20the\x20go\x20command.\x20For\x0aexample,\x20automatic\x20vendoring\x20may\x20be\x20enabled\x20with\x20a\x20go\x20version\x20of\x0a1.14\x20or\x20higher.

\x0a

A\x20go.mod\x20file\x20may\x20contain\x20at\x20most\x20one\x20go\x20directive.\x20Most\x20commands\x20will\x20add\x20a\x0ago\x20directive\x20with\x20the\x20current\x20Go\x20version\x20if\x20one\x20is\x20not\x20present.

\x0a
GoDirective\x20=\x20"go"\x20GoVersion\x20newline\x20.\x0aGoVersion\x20=\x20string\x20|\x20ident\x20.\x20\x20/*\x20valid\x20release\x20version;\x20see\x20above\x20*/\x0a
\x0a

Example:

\x0a
go\x201.14\x0a
\x0arequire\x20directive\x0a

A\x20require\x20directive\x20declares\x20a\x20minimum\x20required\x20version\x20of\x20a\x20given\x20module\x0adependency.\x20For\x20each\x20required\x20module\x20version,\x20the\x20go\x20command\x20loads\x20the\x0ago.mod\x20file\x20for\x20that\x20version\x20and\x20incorporates\x20the\x20requirements\x20from\x20that\x0afile.\x20Once\x20all\x20requirements\x20have\x20been\x20loaded,\x20the\x20go\x20command\x20resolves\x20them\x0ausing\x20minimal\x20version\x20selection\x20(MVS)\x20to\x20produce\x0athe\x20build\x20list.

\x0a

The\x20go\x20command\x20automatically\x20adds\x20//\x20indirect\x20comments\x20for\x20some\x0arequirements.\x20An\x20//\x20indirect\x20comment\x20indicates\x20that\x20no\x20package\x20from\x20the\x0arequired\x20module\x20is\x20directly\x20imported\x20by\x20any\x20package\x20in\x20the\x20main\x20module.\x0aThe\x20go\x20command\x20adds\x20an\x20indirect\x20requirement\x20when\x20the\x20selected\x20version\x20of\x20a\x0amodule\x20is\x20higher\x20than\x20what\x20is\x20already\x20implied\x20(transitively)\x20by\x20the\x20main\x0amodule's\x20other\x20dependencies.\x20That\x20may\x20occur\x20because\x20of\x20an\x20explicit\x20upgrade\x0a(go\x20get\x20-u),\x20removal\x20of\x20some\x20other\x20dependency\x20that\x20previously\x20imposed\x20the\x0arequirement\x20(go\x20mod\x20tidy),\x20or\x20a\x20dependency\x20that\x20imports\x20a\x20package\x20without\x0aa\x20corresponding\x20requirement\x20in\x20its\x20own\x20go.mod\x20file\x20(such\x20as\x20a\x20dependency\x0athat\x20lacks\x20a\x20go.mod\x20file\x20altogether).

\x0a
RequireDirective\x20=\x20"require"\x20(\x20RequireSpec\x20|\x20"("\x20newline\x20{\x20RequireSpec\x20}\x20")"\x20newline\x20)\x20.\x0aRequireSpec\x20=\x20ModulePath\x20Version\x20newline\x20.\x0a
\x0a

Example:

\x0a
require\x20golang.org/x/net\x20v1.2.3\x0a\x0arequire\x20(\x0a\x20\x20\x20\x20golang.org/x/crypto\x20v1.4.5\x20//\x20indirect\x0a\x20\x20\x20\x20golang.org/x/text\x20v1.6.7\x0a)\x0a
\x0aexclude\x20directive\x0a

An\x20exclude\x20directive\x20prevents\x20a\x20module\x20version\x20from\x20being\x20loaded\x20by\x20the\x20go\x0acommand.\x20If\x20an\x20excluded\x20version\x20is\x20referenced\x20by\x20a\x20require\x20directive\x20in\x20a\x0ago.mod\x20file,\x20the\x20go\x20command\x20will\x20list\x20available\x20versions\x20for\x20the\x20module\x20(as\x0ashown\x20with\x20go\x20list\x20-m\x20-versions)\x20and\x20will\x20load\x20the\x20next\x20higher\x20non-excluded\x0aversion\x20instead.\x20Both\x20release\x20and\x20pre-release\x20versions\x20are\x20considered\x20for\x20this\x0apurpose,\x20but\x20pseudo-versions\x20are\x20not.\x20If\x20there\x20are\x20no\x20higher\x20versions,\x0athe\x20go\x20command\x20will\x20report\x20an\x20error.\x20Note\x20that\x20this\x20may\x0achange\x20in\x20Go\x201.15.

\x0a\x0a

exclude\x20directives\x20only\x20apply\x20in\x20the\x20main\x20module's\x20go.mod\x20file\x20and\x20are\x0aignored\x20in\x20other\x20modules.\x20See\x20Minimal\x20version\x0aselection\x20for\x20details.

\x0a
ExcludeDirective\x20=\x20"exclude"\x20(\x20ExcludeSpec\x20|\x20"("\x20newline\x20{\x20ExcludeSpec\x20}\x20")"\x20)\x20.\x0aExcludeSpec\x20=\x20ModulePath\x20Version\x20newline\x20.\x0a
\x0a

Example:

\x0a
exclude\x20golang.org/x/net\x20v1.2.3\x0a\x0aexclude\x20(\x0a\x20\x20\x20\x20golang.org/x/crypto\x20v1.4.5\x0a\x20\x20\x20\x20golang.org/x/text\x20v1.6.7\x0a)\x0a
\x0areplace\x20directive\x0a

A\x20replace\x20directive\x20replaces\x20the\x20contents\x20of\x20a\x20specific\x20version\x20of\x20a\x20module,\x0aor\x20all\x20versions\x20of\x20a\x20module,\x20with\x20contents\x20found\x20elsewhere.\x20The\x20replacement\x0amay\x20be\x20specified\x20with\x20either\x20another\x20module\x20path\x20and\x20version,\x20or\x20a\x0aplatform-specific\x20file\x20path.

\x0a

If\x20a\x20version\x20is\x20present\x20on\x20the\x20left\x20side\x20of\x20the\x20arrow\x20(=>),\x20only\x20that\x20specific\x0aversion\x20of\x20the\x20module\x20is\x20replaced;\x20other\x20versions\x20will\x20be\x20accessed\x20normally.\x0aIf\x20the\x20left\x20version\x20is\x20omitted,\x20all\x20versions\x20of\x20the\x20module\x20are\x20replaced.

\x0a

If\x20the\x20path\x20on\x20the\x20right\x20side\x20of\x20the\x20arrow\x20is\x20an\x20absolute\x20or\x20relative\x20path\x0a(beginning\x20with\x20./\x20or\x20../),\x20it\x20is\x20interpreted\x20as\x20the\x20local\x20file\x20path\x20to\x20the\x0areplacement\x20module\x20root\x20directory,\x20which\x20must\x20contain\x20a\x20go.mod\x20file.\x20The\x0areplacement\x20version\x20must\x20be\x20omitted\x20in\x20this\x20case.

\x0a

If\x20the\x20path\x20on\x20the\x20right\x20side\x20is\x20not\x20a\x20local\x20path,\x20it\x20must\x20be\x20a\x20valid\x20module\x0apath.\x20In\x20this\x20case,\x20a\x20version\x20is\x20required.\x20The\x20same\x20module\x20version\x20must\x20not\x0aalso\x20appear\x20in\x20the\x20build\x20list.

\x0a

Regardless\x20of\x20whether\x20a\x20replacement\x20is\x20specified\x20with\x20a\x20local\x20path\x20or\x20module\x0apath,\x20if\x20the\x20replacement\x20module\x20has\x20a\x20go.mod\x20file,\x20its\x20module\x20directive\x0amust\x20match\x20the\x20module\x20path\x20it\x20replaces.

\x0a

replace\x20directives\x20only\x20apply\x20in\x20the\x20main\x20module's\x20go.mod\x20file\x0aand\x20are\x20ignored\x20in\x20other\x20modules.\x20See\x20Minimal\x20version\x0aselection\x20for\x20details.

\x0a
ReplaceDirective\x20=\x20"replace"\x20(\x20ReplaceSpec\x20|\x20"("\x20newline\x20{\x20ReplaceSpec\x20}\x20")"\x20newline\x20")"\x20)\x20.\x0aReplaceSpec\x20=\x20ModulePath\x20[\x20Version\x20]\x20"=>"\x20FilePath\x20newline\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20|\x20ModulePath\x20[\x20Version\x20]\x20"=>"\x20ModulePath\x20Version\x20newline\x20.\x0aFilePath\x20=\x20/*\x20platform-specific\x20relative\x20or\x20absolute\x20file\x20path\x20*/\x0a
\x0a

Example:

\x0a
replace\x20golang.org/x/net\x20v1.2.3\x20=>\x20example.com/fork/net\x20v1.4.5\x0a\x0areplace\x20(\x0a\x20\x20\x20\x20golang.org/x/net\x20v1.2.3\x20=>\x20example.com/fork/net\x20v1.4.5\x0a\x20\x20\x20\x20golang.org/x/net\x20=>\x20example.com/fork/net\x20v1.4.5\x0a\x20\x20\x20\x20golang.org/x/net\x20v1.2.3\x20=>\x20./fork/net\x0a\x20\x20\x20\x20golang.org/x/net\x20=>\x20./fork/net\x0a)\x0a
\x0aAutomatic\x20updates\x0a

The\x20go\x20command\x20automatically\x20updates\x20go.mod\x20when\x20it\x20uses\x20the\x20module\x20graph\x20if\x0asome\x20information\x20is\x20missing\x20or\x20go.mod\x20doesn't\x20accurately\x20reflect\x20reality.\x20\x20For\x0aexample,\x20consider\x20this\x20go.mod\x20file:

\x0a
module\x20example.com/M\x0a\x0arequire\x20(\x0a\x20\x20\x20\x20example.com/A\x20v1\x0a\x20\x20\x20\x20example.com/B\x20v1.0.0\x0a\x20\x20\x20\x20example.com/C\x20v1.0.0\x0a\x20\x20\x20\x20example.com/D\x20v1.2.3\x0a\x20\x20\x20\x20example.com/E\x20dev\x0a)\x0a\x0aexclude\x20example.com/D\x20v1.2.3\x0a
\x0a

The\x20update\x20rewrites\x20non-canonical\x20version\x20identifiers\x20to\x0acanonical\x20semver\x20form,\x20so\x20example.com/A's\x20v1\x0abecomes\x20v1.0.0,\x20and\x20example.com/E's\x20dev\x20becomes\x20the\x20pseudo-version\x20for\x20the\x0alatest\x20commit\x20on\x20the\x20dev\x20branch,\x20perhaps\x20v0.0.0-20180523231146-b3f5c0f6e5f1.

\x0a

The\x20update\x20modifies\x20requirements\x20to\x20respect\x20exclusions,\x20so\x20the\x20requirement\x20on\x0athe\x20excluded\x20example.com/D\x20v1.2.3\x20is\x20updated\x20to\x20use\x20the\x20next\x20available\x20version\x0aof\x20example.com/D,\x20perhaps\x20v1.2.4\x20or\x20v1.3.0.

\x0a

The\x20update\x20removes\x20redundant\x20or\x20misleading\x20requirements.\x20For\x20example,\x20if\x0aexample.com/A\x20v1.0.0\x20itself\x20requires\x20example.com/B\x20v1.2.0\x20and\x20example.com/C\x20v1.0.0,\x20then\x20go.mod's\x20requirement\x20of\x20example.com/B\x20v1.0.0\x20is\x20misleading\x0a(superseded\x20by\x20example.com/A's\x20need\x20for\x20v1.2.0),\x20and\x20its\x20requirement\x20of\x0aexample.com/C\x20v1.0.0\x20is\x20redundant\x20(implied\x20by\x20example.com/A's\x20need\x20for\x20the\x0asame\x20version),\x20so\x20both\x20will\x20be\x20removed.\x20If\x20the\x20main\x20module\x20contains\x20packages\x0athat\x20directly\x20import\x20packages\x20from\x20example.com/B\x20or\x20example.com/C,\x20then\x20the\x0arequirements\x20will\x20be\x20kept\x20but\x20updated\x20to\x20the\x20actual\x20versions\x20being\x20used.

\x0a

Finally,\x20the\x20update\x20reformats\x20the\x20go.mod\x20in\x20a\x20canonical\x20formatting,\x20so\x0athat\x20future\x20mechanical\x20changes\x20will\x20result\x20in\x20minimal\x20diffs.\x20The\x20go\x20command\x0awill\x20not\x20update\x20go.mod\x20if\x20only\x20formatting\x20changes\x20are\x20needed.

\x0a

Because\x20the\x20module\x20graph\x20defines\x20the\x20meaning\x20of\x20import\x20statements,\x20any\x20commands\x0athat\x20load\x20packages\x20also\x20use\x20and\x20therefore\x20update\x20go.mod,\x20including\x20go\x20build,\x0ago\x20get,\x20go\x20install,\x20go\x20list,\x20go\x20test,\x20go\x20mod\x20graph,\x20go\x20mod\x20tidy,\x20and\x0ago\x20mod\x20why.

\x0a

The\x20-mod=readonly\x20flag\x20prevents\x20commands\x20from\x20automatically\x20updating\x0ago.mod.\x20However,\x20if\x20a\x20command\x20needs\x20to\x20perform\x20an\x20action\x20that\x20would\x0aupdate\x20to\x20go.mod,\x20it\x20will\x20report\x20an\x20error.\x20For\x20example,\x20if\x0ago\x20build\x20is\x20asked\x20to\x20build\x20a\x20package\x20not\x20provided\x20by\x20any\x20module\x20in\x20the\x20build\x0alist,\x20go\x20build\x20will\x20report\x20an\x20error\x20instead\x20of\x20looking\x20up\x20the\x20module\x20and\x0aupdating\x20requirements\x20in\x20go.mod.

\x0aMinimal\x20version\x20selection\x20(MVS)\x0a

Go\x20uses\x20an\x20algorithm\x20called\x20Minimal\x20version\x20selection\x20(MVS)\x20to\x20select\x0aa\x20set\x20of\x20module\x20versions\x20to\x20use\x20when\x20building\x20packages.\x20MVS\x20is\x20described\x20in\x0adetail\x20in\x20Minimal\x20Version\x20Selection\x20by\x0aRuss\x20Cox.

\x0a

Conceptually,\x20MVS\x20operates\x20on\x20a\x20directed\x20graph\x20of\x20modules,\x20specified\x20with\x0ago.mod\x20files.\x20Each\x20vertex\x20in\x20the\x20graph\x20represents\x20a\x0amodule\x20version.\x20Each\x20edge\x20represents\x20a\x20minimum\x20required\x20version\x20of\x20a\x20dependency,\x0aspecified\x20using\x20a\x20require\x0adirective.\x20replace\x20and\x20exclude\x0adirectives\x20in\x20the\x20main\x20module's\x20go.mod\x20file\x20modify\x20the\x20graph.

\x0a

MVS\x20produces\x20the\x20build\x20list\x20as\x20output,\x20the\x20list\x20of\x20module\x0aversions\x20used\x20for\x20a\x20build.

\x0a

MVS\x20starts\x20at\x20the\x20main\x20module\x20(a\x20special\x20vertex\x20in\x20the\x20graph\x20that\x20has\x20no\x0aversion)\x20and\x20traverses\x20the\x20graph,\x20tracking\x20the\x20highest\x20required\x20version\x20of\x20each\x0amodule.\x20At\x20the\x20end\x20of\x20the\x20traversal,\x20the\x20highest\x20required\x20versions\x20comprise\x20the\x0abuild\x20list:\x20they\x20are\x20the\x20minimum\x20versions\x20that\x20satisfy\x20all\x20requirements.

\x0a

The\x20build\x20list\x20may\x20be\x20inspected\x20with\x20the\x20command\x20go\x20list\x20-m\x20all.\x20Unlike\x20other\x20dependency\x20management\x20systems,\x20the\x20build\x20list\x20is\x0anot\x20saved\x20in\x20a\x20"lock"\x20file.\x20MVS\x20is\x20deterministic,\x20and\x20the\x20build\x20list\x20doesn't\x0achange\x20when\x20new\x20versions\x20of\x20dependencies\x20are\x20released,\x20so\x20MVS\x20is\x20used\x20to\x20compute\x0ait\x20at\x20the\x20beginning\x20of\x20every\x20module-aware\x20command.

\x0a

Consider\x20the\x20example\x20in\x20the\x20diagram\x20below.\x20The\x20main\x20module\x20requires\x20module\x20A\x0aat\x20version\x201.2\x20or\x20higher\x20and\x20module\x20B\x20at\x20version\x201.2\x20or\x20higher.\x20A\x201.2\x20and\x20B\x201.2\x0arequire\x20C\x201.3\x20and\x20C\x201.4,\x20respectively.\x20C\x201.3\x20and\x20C\x201.4\x20both\x20require\x20D\x201.2.

\x0a

\x0a

MVS\x20visits\x20and\x20loads\x20the\x20go.mod\x20file\x20for\x20each\x20of\x20the\x20module\x20versions\x0ahighlighted\x20in\x20blue.\x20At\x20the\x20end\x20of\x20the\x20graph\x20traversal,\x20MVS\x20returns\x20a\x20build\x20list\x0acontaining\x20the\x20bolded\x20versions:\x20A\x201.2,\x20B\x201.2,\x20C\x201.4,\x20and\x20D\x201.2.\x20Note\x20that\x20higher\x0aversions\x20of\x20B\x20and\x20D\x20are\x20available\x20but\x20MVS\x20does\x20not\x20select\x20them,\x20since\x20nothing\x0arequires\x20them.

\x0aReplacement\x0a

The\x20content\x20of\x20a\x20module\x20(including\x20its\x20go.mod\x20file)\x20may\x20be\x20replaced\x20using\x20a\x0areplace\x20directive\x20in\x20the\x20the\x20main\x20module's\x20go.mod\x20file.\x0aA\x20replace\x20directive\x20may\x20apply\x20to\x20a\x20specific\x20version\x20of\x20a\x20module\x20or\x20to\x20all\x0aversions\x20of\x20a\x20module.

\x0a

Replacements\x20change\x20the\x20module\x20graph,\x20since\x20a\x20replacement\x20module\x20may\x20have\x0adifferent\x20dependencies\x20than\x20replaced\x20versions.

\x0a

Consider\x20the\x20example\x20below,\x20where\x20C\x201.4\x20has\x20been\x20replaced\x20with\x20R.\x20R\x20depends\x20on\x20D\x0a1.3\x20instead\x20of\x20D\x201.2,\x20so\x20MVS\x20returns\x20a\x20build\x20list\x20containing\x20A\x201.2,\x20B\x201.2,\x20C\x201.4\x0a(replaced\x20with\x20R),\x20and\x20D\x201.3.

\x0a

\x0aExclusion\x0a

A\x20module\x20may\x20also\x20be\x20excluded\x20at\x20specific\x20versions\x20using\x20an\x20exclude\x0adirective\x20in\x20the\x20main\x20module's\x20go.mod\x20file.

\x0a

Exclusions\x20also\x20change\x20the\x20module\x20graph.\x20When\x20a\x20version\x20is\x20excluded,\x20it\x20is\x0aremoved\x20from\x20the\x20module\x20graph,\x20and\x20requirements\x20on\x20it\x20are\x20redirected\x20to\x20the\x0anext\x20higher\x20version.

\x0a

Consider\x20the\x20example\x20below.\x20C\x201.3\x20has\x20been\x20excluded.\x20MVS\x20will\x20act\x20as\x20if\x20A\x201.2\x0arequired\x20C\x201.4\x20(the\x20next\x20higher\x20version)\x20instead\x20of\x20C\x201.3.

\x0a

\x0aUpgrades\x0a

The\x20go\x20get\x20command\x20may\x20be\x20used\x20to\x20upgrade\x20a\x20set\x20of\x20modules.\x20To\x0aperform\x20an\x20upgrade,\x20the\x20go\x20command\x20changes\x20the\x20module\x20graph\x20before\x20running\x20MVS\x0aby\x20adding\x20edges\x20from\x20visited\x20versions\x20to\x20upgraded\x20versions.

\x0a

Consider\x20the\x20example\x20below.\x20Module\x20B\x20may\x20be\x20upgraded\x20from\x201.2\x20to\x201.3,\x20C\x20may\x20be\x0aupgraded\x20from\x201.3\x20to\x201.4,\x20and\x20D\x20may\x20be\x20upgraded\x20from\x201.2\x20to\x201.3.

\x0a

\x0a

Upgrades\x20(and\x20downgrades)\x20may\x20add\x20or\x20remove\x20indirect\x20dependencies.\x20In\x20this\x20case,\x0aE\x201.1\x20and\x20F\x201.1\x20appear\x20in\x20the\x20build\x20list\x20after\x20the\x20upgrade,\x20since\x20E\x201.1\x20is\x0arequired\x20by\x20B\x201.3.

\x0a

To\x20preserve\x20upgrades,\x20the\x20go\x20command\x20updates\x20the\x20requirements\x20in\x20go.mod.\x20\x20It\x0awill\x20change\x20the\x20requirement\x20on\x20B\x20to\x20version\x201.3.\x20It\x20will\x20also\x20add\x20requirements\x0aon\x20C\x201.4\x20and\x20D\x201.3\x20with\x20//\x20indirect\x20comments,\x20since\x20those\x20versions\x20would\x20not\x0abe\x20selected\x20otherwise.

\x0aDowngrade\x0a

The\x20go\x20get\x20command\x20may\x20also\x20be\x20used\x20to\x20downgrade\x20a\x20set\x20of\x0amodules.\x20To\x20perform\x20a\x20downgrade,\x20the\x20go\x20command\x20changes\x20the\x20module\x20graph\x20by\x0aremoving\x20versions\x20above\x20the\x20downgraded\x20versions.\x20It\x20also\x20removes\x20versions\x20of\x0aother\x20modules\x20that\x20depend\x20on\x20removed\x20versions,\x20since\x20they\x20may\x20not\x20be\x20compatible\x0awith\x20the\x20downgraded\x20versions\x20of\x20their\x20dependencies.\x20If\x20the\x20main\x20module\x20requires\x0aa\x20module\x20version\x20removed\x20by\x20downgrading,\x20the\x20requirement\x20is\x20changed\x20to\x20a\x0aprevious\x20version\x20that\x20has\x20not\x20been\x20removed.\x20If\x20no\x20previous\x20version\x20is\x20available,\x0athe\x20requirement\x20is\x20dropped.

\x0a

Consider\x20the\x20example\x20below.\x20Suppose\x20that\x20a\x20problem\x20was\x20found\x20with\x20C\x201.4,\x20so\x20we\x0adowngrade\x20to\x20C\x201.3.\x20C\x201.4\x20is\x20removed\x20from\x20the\x20module\x20graph.\x20B\x201.2\x20is\x20also\x0aremoved,\x20since\x20it\x20requires\x20C\x201.4\x20or\x20higher.\x20The\x20main\x20module's\x20requirement\x20on\x20B\x0ais\x20changed\x20to\x201.1.

\x0a

\x0a

go\x20get\x20can\x20also\x20remove\x20dependencies\x20entirely,\x20using\x20an\x20@none\x0asuffix\x20after\x20an\x20argument.\x20This\x20works\x20similarly\x20to\x20a\x20downgrade.\x20All\x20versions\x0aof\x20the\x20named\x20module\x20are\x20removed\x20from\x20the\x20module\x20graph.

\x0aCompatibility\x20with\x20non-module\x20repositories\x0a

To\x20ensure\x20a\x20smooth\x20transition\x20from\x20GOPATH\x20to\x20modules,\x20the\x20go\x20command\x20can\x0adownload\x20and\x20build\x20packages\x20in\x20module-aware\x20mode\x20from\x20repositories\x20that\x20have\x20not\x0amigrated\x20to\x20modules\x20by\x20adding\x20a\x20go.mod\x20file.

\x0a

When\x20the\x20go\x20command\x20downloads\x20a\x20module\x20at\x20a\x20given\x20version\x20directly\x0afrom\x20a\x20repository,\x20it\x20looks\x20up\x20a\x20repository\x20URL\x20for\x20the\x20module\x20path,\x20maps\x20the\x0aversion\x20to\x20a\x20revision\x20within\x20the\x20repository,\x20then\x20extracts\x20an\x20archive\x20of\x20the\x0arepository\x20at\x20that\x20revision.\x20If\x20the\x20module's\x20path\x20is\x20equal\x0ato\x20the\x20repository\x20root\x20path,\x20and\x20the\x20repository\x0aroot\x20directory\x20does\x20not\x20contain\x20a\x20go.mod\x20file,\x20the\x20go\x20command\x20synthesizes\x20a\x0ago.mod\x20file\x20in\x20the\x20module\x20cache\x20that\x20contains\x20a\x20module\x0adirective\x20and\x20nothing\x20else.\x20Since\x20synthetic\x20go.mod\x20files\x20do\x0anot\x20contain\x20require\x20directives\x20for\x20their\x20dependencies,\x0aother\x20modules\x20that\x20depend\x20on\x20them\x20may\x20need\x20additional\x20require\x20directives\x20(with\x0a//\x20indirect\x20comments)\x20to\x20ensure\x20each\x20dependency\x20is\x20fetched\x20at\x20the\x20same\x20version\x0aon\x20every\x20build.

\x0a

When\x20the\x20go\x20command\x20downloads\x20a\x20module\x20from\x20a\x0aproxy,\x20it\x20downloads\x20the\x20go.mod\x20file\x20separately\x0afrom\x20the\x20rest\x20of\x20the\x20module\x20content.\x20The\x20proxy\x20is\x20expected\x20to\x20serve\x20a\x20synthetic\x0ago.mod\x20file\x20if\x20the\x20original\x20module\x20didn't\x20have\x20one.

\x0a+incompatible\x20versions\x0a

A\x20module\x20released\x20at\x20major\x20version\x202\x20or\x20higher\x20must\x20have\x20a\x20matching\x20major\x0aversion\x20suffix\x20on\x20its\x20module\x20path.\x20For\x20example,\x20if\x20a\x0amodule\x20is\x20released\x20at\x20v2.0.0,\x20its\x20path\x20must\x20have\x20a\x20/v2\x20suffix.\x20This\x20allows\x0athe\x20go\x20command\x20to\x20treat\x20multiple\x20major\x20versions\x20of\x20a\x20project\x20as\x20distinct\x0amodules,\x20even\x20if\x20they're\x20developed\x20in\x20the\x20same\x20repository.

\x0a

The\x20major\x20version\x20suffix\x20requirement\x20was\x20introduced\x20when\x20module\x20support\x20was\x0aadded\x20to\x20the\x20go\x20command,\x20and\x20many\x20repositories\x20had\x20already\x20tagged\x20releases\x0awith\x20major\x20version\x202\x20or\x20higher\x20before\x20that.\x20To\x20maintain\x20compatibility\x20with\x0athese\x20repositories,\x20the\x20go\x20command\x20adds\x20an\x20+incompatible\x20suffix\x20to\x20versions\x0awith\x20major\x20version\x202\x20or\x20higher\x20without\x20a\x20go.mod\x20file.\x20+incompatible\x0aindicates\x20that\x20a\x20version\x20is\x20part\x20of\x20the\x20same\x20module\x20as\x20versions\x20with\x20lower\x20major\x0aversion\x20numbers;\x20consequently,\x20the\x20go\x20command\x20may\x20automatically\x20upgrade\x20to\x0ahigher\x20+incompatible\x20versions\x20even\x20though\x20it\x20may\x20break\x20the\x20build.

\x0a

Consider\x20the\x20example\x20requirement\x20below:

\x0a
require\x20example.com/m\x20v4.1.2+incompatible\x0a
\x0a

The\x20version\x20v4.1.2+incompatible\x20refers\x20to\x20the\x20semantic\x20version\x0atag\x20v4.1.2\x20in\x20the\x20repository\x20that\x20provides\x20the\x0amodule\x20example.com/m.\x20The\x20module\x20must\x20be\x20in\x20the\x20repository\x20root\x20directory\x0a(that\x20is,\x20the\x20repository\x20root\x20path\x20must\x20also\x20be\x0aexample.com/m),\x20and\x20a\x20go.mod\x20file\x20must\x20not\x20be\x20present.\x20The\x20module\x20may\x20have\x0aversions\x20with\x20lower\x20major\x20version\x20numbers\x20like\x20v1.5.2,\x20and\x20the\x20go\x20command\x0amay\x20upgrade\x20automatically\x20to\x20v4.1.2+incompatible\x20from\x20those\x20versions\x20(see\x0aminimal\x20version\x20selection\x20(MVS)\x20for\x20information\x0aon\x20how\x20upgrades\x20work).

\x0a

A\x20repository\x20that\x20migrates\x20to\x20modules\x20after\x20version\x20v2.0.0\x20is\x20tagged\x20should\x0ausually\x20release\x20a\x20new\x20major\x20version.\x20In\x20the\x20example\x20above,\x20the\x20author\x20should\x0acreate\x20a\x20module\x20with\x20the\x20path\x20example.com/m/v5\x20and\x20should\x20release\x20version\x0av5.0.0.\x20The\x20author\x20should\x20also\x20update\x20imports\x20of\x20packages\x20in\x20the\x20module\x20to\x20use\x0athe\x20prefix\x20example.com/m/v5\x20instead\x20of\x20example.com/m.\x20See\x20Go\x20Modules:\x20v2\x0aand\x20Beyond\x20for\x20a\x20more\x20detailed\x20example.

\x0a

Note\x20that\x20the\x20+incompatible\x20suffix\x20should\x20not\x20appear\x20on\x20a\x20tag\x20in\x20a\x20repository;\x0aa\x20tag\x20like\x20v4.1.2+incompatible\x20will\x20be\x20ignored.\x20The\x20suffix\x20only\x20appears\x20in\x0aversions\x20used\x20by\x20the\x20go\x20command.\x20See\x20Mapping\x20versions\x20to\x0acommits\x20for\x20details\x20on\x20the\x20distinction\x20between\x20versions\x20and\x20tags.

\x0a

Note\x20also\x20that\x20the\x20+incompatible\x20suffix\x20may\x20appear\x20on\x0apseudo-versions.\x20For\x20example,\x0av2.0.1-20200722182040-012345abcdef+incompatible\x20may\x20be\x20a\x20valid\x20pseudo-version.

\x0aMinimal\x20module\x20compatibility\x0a

A\x20module\x20released\x20at\x20major\x20version\x202\x20or\x20higher\x20is\x20required\x20to\x20have\x20a\x20major\x0aversion\x20suffix\x20on\x20its\x20module\x0apath.\x20The\x20module\x20may\x20or\x20may\x20not\x20be\x20developed\x20in\x20a\x20major\x0aversion\x20subdirectory\x20within\x20its\x20repository.\x0aThis\x20has\x20implications\x20for\x20packages\x20that\x20import\x20packages\x20within\x20the\x20module\x20when\x0abuilding\x20GOPATH\x20mode.

\x0a

Normally\x20in\x20GOPATH\x20mode,\x20a\x20package\x20is\x20stored\x20in\x20a\x20directory\x20matching\x20its\x0arepository's\x20root\x20path\x20joined\x20with\x20its\x20diretory\x0awithin\x20the\x20repository.\x20For\x20example,\x20a\x20package\x20in\x20the\x20repository\x20with\x20root\x20path\x0aexample.com/repo\x20in\x20the\x20subdirectory\x20sub\x20would\x20be\x20stored\x20in\x0a$GOPATH/src/example.com/repo/sub\x20and\x20would\x20be\x20imported\x20as\x0aexample.com/repo/sub.

\x0a

For\x20a\x20module\x20with\x20a\x20major\x20version\x20suffix,\x20one\x20might\x20expect\x20to\x20find\x20the\x20package\x0aexample.com/repo/v2/sub\x20in\x20the\x20directory\x0a$GOPATH/src/example.com/repo/v2/sub.\x20This\x20would\x20require\x20the\x20module\x20to\x20be\x0adeveloped\x20in\x20the\x20v2\x20subdirectory\x20of\x20its\x20repository.\x20The\x20go\x20command\x20supports\x0athis\x20but\x20does\x20not\x20require\x20it\x20(see\x20Mapping\x20versions\x20to\x20commits).

\x0a

If\x20a\x20module\x20is\x20not\x20developed\x20in\x20a\x20major\x20version\x20subdirectory,\x20then\x20its\x0adirectory\x20in\x20GOPATH\x20will\x20not\x20contain\x20the\x20major\x20version\x20suffix,\x20and\x20its\x0apackages\x20may\x20be\x20imported\x20without\x20the\x20major\x20version\x20suffix.\x20In\x20the\x20example\x20above,\x0athe\x20package\x20would\x20be\x20found\x20in\x20the\x20directory\x20$GOPATH/src/example.com/repo/sub\x0aand\x20would\x20be\x20imported\x20as\x20example.com/repo/sub.

\x0a

This\x20creates\x20a\x20problem\x20for\x20packages\x20intended\x20to\x20be\x20built\x20in\x20both\x20module\x20mode\x0aand\x20GOPATH\x20mode:\x20module\x20mode\x20requires\x20a\x20suffix,\x20while\x20GOPATH\x20mode\x20does\x20not.

\x0a

To\x20fix\x20this,\x20minimal\x20module\x20compatibility\x20was\x20added\x20in\x20Go\x201.11\x20and\x0awas\x20backported\x20to\x20Go\x201.9.7\x20and\x201.10.3.\x20When\x20an\x20import\x20path\x20is\x20resolved\x20to\x20a\x0adirectory\x20in\x20GOPATH\x20mode:

\x0a
    \x0a
  • When\x20resolving\x20an\x20import\x20of\x20the\x20form\x20$modpath/$vn/$dir\x20where:\x0a
      \x0a
    • $modpath\x20is\x20a\x20valid\x20module\x20path,
    • \x0a
    • $vn\x20is\x20a\x20major\x20version\x20suffix,
    • \x0a
    • $dir\x20is\x20a\x20possibly\x20empty\x20subdirectory,
    • \x0a
    \x0a
  • \x0a
  • If\x20all\x20of\x20the\x20following\x20are\x20true:\x0a
      \x0a
    • The\x20package\x20$modpath/$vn/$dir\x20is\x20not\x20present\x20in\x20any\x20relevant\x20vendor\x0adirectory.
    • \x0a
    • A\x20go.mod\x20file\x20is\x20present\x20in\x20the\x20same\x20directory\x20as\x20the\x20importing\x20file\x0aor\x20in\x20any\x20parent\x20directory\x20up\x20to\x20the\x20$GOPATH/src\x20root,
    • \x0a
    • No\x20$GOPATH[i]/src/$modpath/$vn/$suffix\x20directory\x20exists\x20(for\x20any\x20root\x0a$GOPATH[i]),
    • \x0a
    • The\x20file\x20$GOPATH[d]/src/$modpath/go.mod\x20exists\x20(for\x20some\x20root\x0a$GOPATH[d])\x20and\x20declares\x20the\x20module\x20path\x20as\x20$modpath/$vn,
    • \x0a
    \x0a
  • \x0a
  • Then\x20the\x20import\x20of\x20$modpath/$vn/$dir\x20is\x20resolved\x20to\x20the\x20directory\x0a$GOPATH[d]/src/$modpath/$dir.
  • \x0a
\x0a

This\x20rules\x20allow\x20packages\x20that\x20have\x20been\x20migrated\x20to\x20modules\x20to\x20import\x20other\x0apackages\x20that\x20have\x20been\x20migrated\x20to\x20modules\x20when\x20built\x20in\x20GOPATH\x20mode\x20even\x0awhen\x20a\x20major\x20version\x20subdirectory\x20was\x20not\x20used.

\x0aModule-aware\x20commands\x0a

Most\x20go\x20commands\x20may\x20run\x20in\x20Module-aware\x20mode\x20or\x20GOPATH\x20mode.\x20In\x0amodule-aware\x20mode,\x20the\x20go\x20command\x20uses\x20go.mod\x20files\x20to\x20find\x20versioned\x0adependencies,\x20and\x20it\x20typically\x20loads\x20packages\x20out\x20of\x20the\x20module\x0acache,\x20downloading\x20modules\x20if\x20they\x20are\x20missing.\x20In\x20GOPATH\x0amode,\x20the\x20go\x20command\x20ignores\x20modules;\x20it\x20looks\x20in\x20vendor\x0adirectories\x20and\x20in\x20GOPATH\x20to\x20find\x20dependencies.

\x0a

Module-aware\x20mode\x20is\x20active\x20by\x20default\x20whenever\x20a\x20go.mod\x20file\x20is\x20found\x20in\x20the\x0acurrent\x20directory\x20or\x20in\x20any\x20parent\x20directory.\x20For\x20more\x20fine-grained\x20control,\x20the\x0aGO111MODULE\x20environment\x20variable\x20may\x20be\x20set\x20to\x20one\x20of\x20three\x20values:\x20on,\x0aoff,\x20or\x20auto.

\x0a
    \x0a
  • If\x20GO111MODULE=off,\x20the\x20go\x20command\x20ignores\x20go.mod\x20files\x20and\x20runs\x20in\x0aGOPATH\x20mode.
  • \x0a
  • If\x20GO111MODULE=on,\x20the\x20go\x20command\x20runs\x20in\x20module-aware\x20mode,\x20even\x20when\x0ano\x20go.mod\x20file\x20is\x20present.\x20Not\x20all\x20commands\x20work\x20without\x20a\x20go.mod\x20file:\x0asee\x20Module\x20commands\x20outside\x20a\x20module.
  • \x0a
  • If\x20GO111MODULE=auto\x20or\x20is\x20unset,\x20the\x20go\x20command\x20runs\x20in\x20module-aware\x0amode\x20if\x20a\x20go.mod\x20file\x20is\x20present\x20in\x20the\x20current\x20directory\x20or\x20any\x20parent\x0adirectory\x20(the\x20default\x20behavior).
  • \x0a
\x0a

In\x20module-aware\x20mode,\x20GOPATH\x20no\x20longer\x20defines\x20the\x20meaning\x20of\x20imports\x20during\x20a\x0abuild,\x20but\x20it\x20still\x20stores\x20downloaded\x20dependencies\x20(in\x20GOPATH/pkg/mod;\x20see\x0aModule\x20cache)\x20and\x20installed\x20commands\x20(in\x20GOPATH/bin,\x20unless\x0aGOBIN\x20is\x20set).

\x0aBuild\x20commands\x0a

All\x20commands\x20that\x20load\x20information\x20about\x20packages\x20are\x20module-aware.\x20This\x0aincludes:

\x0a
    \x0a
  • go\x20build
  • \x0a
  • go\x20fix
  • \x0a
  • go\x20generate
  • \x0a
  • go\x20get
  • \x0a
  • go\x20install
  • \x0a
  • go\x20list
  • \x0a
  • go\x20run
  • \x0a
  • go\x20test
  • \x0a
  • go\x20vet
  • \x0a
\x0a

When\x20run\x20in\x20module-aware\x20mode,\x20these\x20commands\x20use\x20go.mod\x20files\x20to\x20interpret\x0aimport\x20paths\x20listed\x20on\x20the\x20command\x20line\x20or\x20written\x20in\x20Go\x20source\x20files.\x20These\x0acommands\x20accept\x20the\x20following\x20flags,\x20common\x20to\x20all\x20module\x20commands.

\x0a
    \x0a
  • The\x20-mod\x20flag\x20controls\x20whether\x20go.mod\x20may\x20be\x20automatically\x20updated\x20and\x0awhether\x20the\x20vendor\x20directory\x20is\x20used.\x0a
      \x0a
    • -mod=mod\x20tells\x20the\x20go\x20command\x20to\x20ignore\x20the\x20vendor\x20directory\x20and\x20to\x0aautomatically\x20update\x20go.mod,\x20for\x20example,\x20when\x20an\x0aimported\x20package\x20is\x20not\x20provided\x20by\x20any\x20known\x20module.
    • \x0a
    • -mod=readonly\x20tells\x20the\x20go\x20command\x20to\x20ignore\x20the\x20vendor\x20directory\x20and\x0ato\x20report\x20an\x20error\x20if\x20go.mod\x20needs\x20to\x20be\x20updated.
    • \x0a
    • -mod=vendor\x20tells\x20the\x20go\x20command\x20to\x20use\x20the\x20vendor\x20directory.\x20In\x20this\x0amode,\x20the\x20go\x20command\x20will\x20not\x20use\x20the\x20network\x20or\x20the\x20module\x20cache.
    • \x0a
    • By\x20default,\x20if\x20the\x20go\x20version\x20in\x20go.mod\x20is\x201.14\x20or\x0ahigher\x20and\x20a\x20vendor\x20directory\x20is\x20present,\x20the\x20go\x20command\x20will\x20act\x20as\x20if\x0a-mod=vendor\x20were\x20used.\x20Otherwise,\x20the\x20go\x20command\x20will\x20act\x20as\x20if\x0a-mod=mod\x20were\x20used.
    • \x0a
    \x0a
  • \x0a
  • The\x20-modcacherw\x20flag\x20instructs\x20the\x20go\x20command\x20to\x20create\x20new\x20directories\x0ain\x20the\x20module\x20cache\x20with\x20read-write\x20permissions\x20instead\x20of\x20making\x20them\x0aread-only.\x20When\x20this\x20flag\x20is\x20used\x20consistently\x20(typically\x20by\x20setting\x0aGOFLAGS=-modcacherw\x20in\x20the\x20environment\x20or\x20by\x20running\x0ago\x20env\x20-w\x20GOFLAGS=-modcacherw),\x20the\x20module\x20cache\x20may\x20be\x20deleted\x20with\x0acommands\x20like\x20rm\x20-r\x20without\x20changing\x20permissions\x20first.\x20The\x0ago\x20clean\x20-modcache\x20command\x20may\x20be\x20used\x20to\x20delete\x20the\x0amodule\x20cache,\x20whether\x20or\x20not\x20-modcacherw\x20was\x20used.
  • \x0a
  • The\x20-modfile=file.mod\x20flag\x20instructs\x20the\x20go\x20command\x20to\x20read\x20(and\x20possibly\x0awrite)\x20an\x20alternate\x20file\x20instead\x20of\x20go.mod\x20in\x20the\x20module\x20root\x20directory.\x20The\x0afile's\x20name\x20must\x20end\x20with\x20.mod.\x20A\x20file\x20named\x20go.mod\x20must\x20still\x20be\x20present\x0ain\x20order\x20to\x20determine\x20the\x20module\x20root\x20directory,\x20but\x20it\x20is\x20not\x20accessed.\x20When\x0a-modfile\x20is\x20specified,\x20an\x20alternate\x20go.sum\x20file\x20is\x20also\x20used:\x20its\x20path\x20is\x0aderived\x20from\x20the\x20-modfile\x20flag\x20by\x20trimming\x20the\x20.mod\x20extension\x20and\x0aappending\x20.sum.
  • \x0a
\x0aVendoring\x0a

When\x20using\x20modules,\x20the\x20go\x20command\x20typically\x20satisfies\x20dependencies\x20by\x0adownloading\x20modules\x20from\x20their\x20sources\x20into\x20the\x20module\x20cache,\x20then\x20loading\x0apackages\x20from\x20those\x20downloaded\x20copies.\x20Vendoring\x20may\x20be\x20used\x20to\x20allow\x0ainteroperation\x20with\x20older\x20versions\x20of\x20Go,\x20or\x20to\x20ensure\x20that\x20all\x20files\x20used\x20for\x20a\x0abuild\x20are\x20stored\x20in\x20a\x20single\x20file\x20tree.

\x0a

The\x20go\x20mod\x20vendor\x20command\x20constructs\x20a\x20directory\x20named\x20vendor\x20in\x20the\x20main\x0amodule's\x20root\x20directory\x20containing\x20copies\x20of\x20all\x20packages\x0aneeded\x20to\x20build\x20and\x20test\x20packages\x20in\x20the\x20main\x20module.\x20Packages\x20that\x20are\x20only\x0aimported\x20by\x20tests\x20of\x20packages\x20outside\x20the\x20main\x20module\x20are\x20not\x20included.\x20As\x20with\x0ago\x20mod\x20tidy\x20and\x20other\x20module\x20commands,\x20build\x0aconstraints\x20except\x20for\x20ignore\x20are\x20not\x20considered\x20when\x0aconstructing\x20the\x20vendor\x20directory.

\x0a

go\x20mod\x20vendor\x20also\x20creates\x20the\x20file\x20vendor/modules.txt\x20that\x20contains\x20a\x20list\x0aof\x20vendored\x20packages\x20and\x20the\x20module\x20versions\x20they\x20were\x20copied\x20from.\x20When\x0avendoring\x20is\x20enabled,\x20this\x20manifest\x20is\x20used\x20as\x20a\x20source\x20of\x20module\x20version\x0ainformation,\x20as\x20reported\x20by\x20go\x20list\x20-m\x20and\x20go\x20version\x20-m.\x20When\x20the\x20go\x20command\x20reads\x20vendor/modules.txt,\x20it\x20checks\x0athat\x20the\x20module\x20versions\x20are\x20consistent\x20with\x20go.mod.\x20If\x20go.mod\x20has\x20changed\x0asince\x20vendor/modules.txt\x20was\x20generated,\x20the\x20go\x20command\x20will\x20report\x20an\x20error.\x0ago\x20mod\x20vendor\x20should\x20be\x20run\x20again\x20to\x20update\x20the\x20vendor\x20directory.

\x0a

If\x20the\x20vendor\x20directory\x20is\x20present\x20in\x20the\x20main\x20module's\x20root\x20directory,\x20it\x0awill\x20be\x20used\x20automatically\x20if\x20the\x20go\x20version\x20in\x20the\x20main\x0amodule's\x20go.mod\x20file\x20is\x201.14\x20or\x20higher.\x20To\x20explicitly\x0aenable\x20vendoring,\x20invoke\x20the\x20go\x20command\x20with\x20the\x20flag\x20-mod=vendor.\x20To\x0adisable\x20vendoring,\x20use\x20the\x20flag\x20-mod=mod.

\x0a

When\x20vendoring\x20is\x20enabled,\x20build\x20commands\x20like\x20go\x20build\x20and\x0ago\x20test\x20load\x20packages\x20from\x20the\x20vendor\x20directory\x20instead\x20of\x20accessing\x20the\x0anetwork\x20or\x20the\x20local\x20module\x20cache.\x20The\x20go\x20list\x20-m\x20command\x20only\x0aprints\x20information\x20about\x20modules\x20listed\x20in\x20go.mod.\x20go\x20mod\x20commands\x20such\x20as\x0ago\x20mod\x20download\x20and\x20go\x20mod\x20tidy\x20do\x20not\x0awork\x20differently\x20when\x20vendoring\x20is\x20enabled\x20and\x20will\x20still\x20download\x20modules\x20and\x0aaccess\x20the\x20module\x20cache.\x20go\x20get\x20also\x20does\x20not\x20work\x20differently\x20when\x0avendoring\x20is\x20enabled.

\x0a

Unlike\x20vendoring\x20in\x20GOPATH,\x20the\x20go\x0acommand\x20ignores\x20vendor\x20directories\x20in\x20locations\x20other\x20than\x20the\x20main\x20module's\x0aroot\x20directory.

\x0ago\x20get\x0a

Usage:

\x0a
go\x20get\x20[-d]\x20[-t]\x20[-u]\x20[build\x20flags]\x20[packages]\x0a
\x0a

Examples:

\x0a
#\x20Install\x20the\x20latest\x20version\x20of\x20a\x20tool.\x0a$\x20go\x20get\x20golang.org/x/tools/cmd/goimports\x0a\x0a#\x20Upgrade\x20a\x20specific\x20module.\x0a$\x20go\x20get\x20-d\x20golang.org/x/net\x0a\x0a#\x20Upgrade\x20modules\x20that\x20provide\x20packages\x20imported\x20by\x20packages\x20in\x20the\x20main\x20module.\x0a$\x20go\x20get\x20-d\x20-u\x20./...\x0a\x0a#\x20Upgrade\x20or\x20downgrade\x20to\x20a\x20specific\x20version\x20of\x20a\x20module.\x0a$\x20go\x20get\x20-d\x20golang.org/x/text@v0.3.2\x0a\x0a#\x20Update\x20to\x20the\x20commit\x20on\x20the\x20module's\x20master\x20branch.\x0a$\x20go\x20get\x20-d\x20golang.org/x/text@master\x0a\x0a#\x20Remove\x20a\x20dependency\x20on\x20a\x20module\x20and\x20downgrade\x20modules\x20that\x20require\x20it\x0a#\x20to\x20versions\x20that\x20don't\x20require\x20it.\x0a$\x20go\x20get\x20-d\x20golang.org/x/text@none\x0a
\x0a

The\x20go\x20get\x20command\x20updates\x20module\x20dependencies\x20in\x20the\x20go.mod\x0afile\x20for\x20the\x20main\x20module,\x20then\x20builds\x20and\x0ainstalls\x20packages\x20listed\x20on\x20the\x20command\x20line.

\x0a

The\x20first\x20step\x20is\x20to\x20determine\x20which\x20modules\x20to\x20update.\x20go\x20get\x20accepts\x20a\x20list\x0aof\x20packages,\x20package\x20patterns,\x20and\x20module\x20paths\x20as\x20arguments.\x20If\x20a\x20package\x0aargument\x20is\x20specified,\x20go\x20get\x20updates\x20the\x20module\x20that\x20provides\x20the\x20package.\x0aIf\x20a\x20package\x20pattern\x20is\x20specified\x20(for\x20example,\x20all\x20or\x20a\x20path\x20with\x20a\x20...\x0awildcard),\x20go\x20get\x20expands\x20the\x20pattern\x20to\x20a\x20set\x20of\x20packages,\x20then\x20updates\x20the\x0amodules\x20that\x20provide\x20the\x20packages.\x20If\x20an\x20argument\x20names\x20a\x20module\x20but\x20not\x20a\x0apackage\x20(for\x20example,\x20the\x20module\x20golang.org/x/net\x20has\x20no\x20package\x20in\x20its\x20root\x0adirectory),\x20go\x20get\x20will\x20update\x20the\x20module\x20but\x20will\x20not\x20build\x20a\x20package.\x20If\x20no\x0aarguments\x20are\x20specified,\x20go\x20get\x20acts\x20as\x20if\x20.\x20were\x20specified\x20(the\x20package\x20in\x0athe\x20current\x20directory);\x20this\x20may\x20be\x20used\x20together\x20with\x20the\x20-u\x20flag\x20to\x20update\x0amodules\x20that\x20provide\x20imported\x20packages.

\x0a

Each\x20argument\x20may\x20include\x20a\x20version\x20query\x20suffix\x20indicating\x20the\x0adesired\x20version,\x20as\x20in\x20go\x20get\x20golang.org/x/text@v0.3.0.\x20A\x20version\x20query\x0asuffix\x20consists\x20of\x20an\x20@\x20symbol\x20followed\x20by\x20a\x20version\x20query,\x0awhich\x20may\x20indicate\x20a\x20specific\x20version\x20(v0.3.0),\x20a\x20version\x20prefix\x20(v0.3),\x0aa\x20branch\x20or\x20tag\x20name\x20(master),\x20a\x20revision\x20(1234abcd),\x20or\x20one\x20of\x20the\x20special\x0aqueries\x20latest,\x20upgrade,\x20patch,\x20or\x20none.\x20If\x20no\x20version\x20is\x20given,\x0ago\x20get\x20uses\x20the\x20@upgrade\x20query.

\x0a

Once\x20go\x20get\x20has\x20resolved\x20its\x20arguments\x20to\x20specific\x20modules\x20and\x20versions,\x20go\x20get\x20will\x20add,\x20change,\x20or\x20remove\x20require\x20directives\x20in\x20the\x0amain\x20module's\x20go.mod\x20file\x20to\x20ensure\x20the\x20modules\x20remain\x20at\x20the\x20desired\x0aversions\x20in\x20the\x20future.\x20Note\x20that\x20required\x20versions\x20in\x20go.mod\x20files\x20are\x0aminimum\x20versions\x20and\x20may\x20be\x20increased\x20automatically\x20as\x20new\x20dependencies\x20are\x0aadded.\x20See\x20Minimal\x20version\x20selection\x20(MVS)\x20for\x0adetails\x20on\x20how\x20versions\x20are\x20selected\x20and\x20conflicts\x20are\x20resolved\x20by\x20module-aware\x0acommands.

\x0a

Other\x20modules\x20may\x20be\x20upgraded\x20when\x20a\x20module\x20named\x20on\x20the\x20command\x20line\x20is\x20added,\x0aupgraded,\x20or\x20downgraded\x20if\x20the\x20new\x20version\x20of\x20the\x20named\x20module\x20requires\x20other\x0amodules\x20at\x20higher\x20versions.\x20For\x20example,\x20suppose\x20module\x20example.com/a\x20is\x0aupgraded\x20to\x20version\x20v1.5.0,\x20and\x20that\x20version\x20requires\x20module\x20example.com/b\x0aat\x20version\x20v1.2.0.\x20If\x20module\x20example.com/b\x20is\x20currently\x20required\x20at\x20version\x0av1.1.0,\x20go\x20get\x20example.com/a@v1.5.0\x20will\x20also\x20upgrade\x20example.com/b\x20to\x0av1.2.0.

\x0a

\x0a

Other\x20modules\x20may\x20be\x20downgraded\x20when\x20a\x20module\x20named\x20on\x20the\x20command\x20line\x20is\x0adowngraded\x20or\x20removed.\x20To\x20continue\x20the\x20above\x20example,\x20suppose\x20module\x0aexample.com/b\x20is\x20downgraded\x20to\x20v1.1.0.\x20Module\x20example.com/a\x20would\x20also\x20be\x0adowngraded\x20to\x20a\x20version\x20that\x20requires\x20example.com/b\x20at\x20version\x20v1.1.0\x20or\x0alower.

\x0a

\x0a

A\x20module\x20requirement\x20may\x20be\x20removed\x20using\x20the\x20version\x20suffix\x20@none.\x20This\x20is\x20a\x0aspecial\x20kind\x20of\x20downgrade.\x20Modules\x20that\x20depend\x20on\x20the\x20removed\x20module\x20will\x20be\x0adowngraded\x20or\x20removed\x20as\x20needed.\x20A\x20module\x20requirement\x20may\x20be\x20removed\x20even\x20if\x20one\x0aor\x20more\x20of\x20its\x20packages\x20are\x20imported\x20by\x20packages\x20in\x20the\x20main\x20module.\x20In\x20this\x0acase,\x20the\x20next\x20build\x20command\x20may\x20add\x20a\x20new\x20module\x20requirement.

\x0a

If\x20a\x20module\x20is\x20needed\x20at\x20two\x20different\x20versions\x20(specified\x20explicitly\x20in\x20command\x0aline\x20arguments\x20or\x20to\x20satisfy\x20upgrades\x20and\x20downgrades),\x20go\x20get\x20will\x20report\x20an\x0aerror.

\x0a

After\x20go\x20get\x20updates\x20the\x20go.mod\x20file,\x20it\x20builds\x20the\x20packages\x20named\x0aon\x20the\x20command\x20line.\x20Executables\x20will\x20be\x20installed\x20in\x20the\x20directory\x20named\x20by\x0athe\x20GOBIN\x20environment\x20variable,\x20which\x20defaults\x20to\x20$GOPATH/bin\x20or\x0a$HOME/go/bin\x20if\x20the\x20GOPATH\x20environment\x20variable\x20is\x20not\x20set.

\x0a

go\x20get\x20supports\x20the\x20following\x20flags:

\x0a
    \x0a
  • The\x20-d\x20flag\x20tells\x20go\x20get\x20not\x20to\x20build\x20or\x20install\x20packages.\x20When\x20-d\x20is\x0aused,\x20go\x20get\x20will\x20only\x20manage\x20dependencies\x20in\x20go.mod.
  • \x0a
  • The\x20-u\x20flag\x20tells\x20go\x20get\x20to\x20upgrade\x20modules\x20providing\x20packages\x0aimported\x20directly\x20or\x20indirectly\x20by\x20packages\x20named\x20on\x20the\x20command\x20line.\x0aEach\x20module\x20selected\x20by\x20-u\x20will\x20be\x20upgraded\x20to\x20its\x20latest\x20version\x20unless\x0ait\x20is\x20already\x20required\x20at\x20a\x20higher\x20version\x20(a\x20pre-release).
  • \x0a
  • The\x20-u=patch\x20flag\x20(not\x20-u\x20patch)\x20also\x20tells\x20go\x20get\x20to\x20upgrade\x0adependencies,\x20but\x20go\x20get\x20will\x20upgrade\x20each\x20dependency\x20to\x20the\x20latest\x20patch\x0aversion\x20(similar\x20to\x20the\x20@patch\x20version\x20query).
  • \x0a
  • The\x20-t\x20flag\x20tells\x20go\x20get\x20to\x20consider\x20modules\x20needed\x20to\x20build\x20tests\x0aof\x20packages\x20named\x20on\x20the\x20command\x20line.\x20When\x20-t\x20and\x20-u\x20are\x20used\x20together,\x0ago\x20get\x20will\x20update\x20test\x20dependencies\x20as\x20well.
  • \x0a
  • The\x20-insecure\x20flag\x20should\x20no\x20longer\x20be\x20used.\x20It\x20permits\x20go\x20get\x20to\x20resolve\x0acustom\x20import\x20paths\x20and\x20fetch\x20from\x20repositories\x20and\x20module\x20proxies\x20using\x0ainsecure\x20schemes\x20such\x20as\x20HTTP.\x20The\x20GOINSECURE\x20environment\x0avariable\x20provides\x20more\x20fine-grained\x20control\x20and\x0ashould\x20be\x20used\x20instead.
  • \x0a
\x0ago\x20list\x20-m\x0a

Usage:

\x0a
go\x20list\x20-m\x20[-u]\x20[-versions]\x20[list\x20flags]\x20[modules]\x0a
\x0a

Example:

\x0a
$\x20go\x20list\x20-m\x20all\x0a$\x20go\x20list\x20-m\x20-versions\x20example.com/m\x0a$\x20go\x20list\x20-m\x20-json\x20example.com/m@latest\x0a
\x0a

The\x20-m\x20flag\x20causes\x20go\x20list\x20to\x20list\x20modules\x20instead\x20of\x20packages.\x20In\x20this\x0amode,\x20the\x20arguments\x20to\x20go\x20list\x20may\x20be\x20modules,\x20module\x20patterns\x20(containing\x20the\x0a...\x20wildcard),\x20version\x20queries,\x20or\x20the\x20special\x20pattern\x0aall,\x20which\x20matches\x20all\x20modules\x20in\x20the\x20build\x20list.\x20If\x20no\x0aarguments\x20are\x20specified,\x20the\x20main\x20module\x20is\x20listed.

\x0a

When\x20listing\x20modules,\x20the\x20-f\x20flag\x20still\x20specifies\x20a\x20format\x20template\x20applied\x0ato\x20a\x20Go\x20struct,\x20but\x20now\x20a\x20Module\x20struct:

\x0a
type\x20Module\x20struct\x20{\x0a\x20\x20\x20\x20Path\x20\x20\x20\x20\x20\x20string\x20\x20\x20\x20\x20\x20\x20//\x20module\x20path\x0a\x20\x20\x20\x20Version\x20\x20\x20string\x20\x20\x20\x20\x20\x20\x20//\x20module\x20version\x0a\x20\x20\x20\x20Versions\x20\x20[]string\x20\x20\x20\x20\x20//\x20available\x20module\x20versions\x20(with\x20-versions)\x0a\x20\x20\x20\x20Replace\x20\x20\x20*Module\x20\x20\x20\x20\x20\x20//\x20replaced\x20by\x20this\x20module\x0a\x20\x20\x20\x20Time\x20\x20\x20\x20\x20\x20*time.Time\x20\x20\x20//\x20time\x20version\x20was\x20created\x0a\x20\x20\x20\x20Update\x20\x20\x20\x20*Module\x20\x20\x20\x20\x20\x20//\x20available\x20update,\x20if\x20any\x20(with\x20-u)\x0a\x20\x20\x20\x20Main\x20\x20\x20\x20\x20\x20bool\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20is\x20this\x20the\x20main\x20module?\x0a\x20\x20\x20\x20Indirect\x20\x20bool\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20is\x20this\x20module\x20only\x20an\x20indirect\x20dependency\x20of\x20main\x20module?\x0a\x20\x20\x20\x20Dir\x20\x20\x20\x20\x20\x20\x20string\x20\x20\x20\x20\x20\x20\x20//\x20directory\x20holding\x20files\x20for\x20this\x20module,\x20if\x20any\x0a\x20\x20\x20\x20GoMod\x20\x20\x20\x20\x20string\x20\x20\x20\x20\x20\x20\x20//\x20path\x20to\x20go.mod\x20file\x20for\x20this\x20module,\x20if\x20any\x0a\x20\x20\x20\x20GoVersion\x20string\x20\x20\x20\x20\x20\x20\x20//\x20go\x20version\x20used\x20in\x20module\x0a\x20\x20\x20\x20Error\x20\x20\x20\x20\x20*ModuleError\x20//\x20error\x20loading\x20module\x0a}\x0a\x0atype\x20ModuleError\x20struct\x20{\x0a\x20\x20\x20\x20Err\x20string\x20//\x20the\x20error\x20itself\x0a}\x0a
\x0a

The\x20default\x20output\x20is\x20to\x20print\x20the\x20module\x20path\x20and\x20then\x20information\x20about\x20the\x0aversion\x20and\x20replacement\x20if\x20any.\x20For\x20example,\x20go\x20list\x20-m\x20all\x20might\x20print:

\x0a
example.com/main/module\x0agolang.org/x/text\x20v0.3.0\x20=>\x20/tmp/text\x0arsc.io/pdf\x20v0.1.1\x0a
\x0a

The\x20Module\x20struct\x20has\x20a\x20String\x20method\x20that\x20formats\x20this\x20line\x20of\x20output,\x20so\x0athat\x20the\x20default\x20format\x20is\x20equivalent\x20to\x20-f\x20'{{.String}}'.

\x0a

Note\x20that\x20when\x20a\x20module\x20has\x20been\x20replaced,\x20its\x20Replace\x20field\x20describes\x20the\x0areplacement\x20module\x20module,\x20and\x20its\x20Dir\x20field\x20is\x20set\x20to\x20the\x20replacement\x0amodule's\x20source\x20code,\x20if\x20present.\x20(That\x20is,\x20if\x20Replace\x20is\x20non-nil,\x20then\x20Dir\x0ais\x20set\x20to\x20Replace.Dir,\x20with\x20no\x20access\x20to\x20the\x20replaced\x20source\x20code.)

\x0a

The\x20-u\x20flag\x20adds\x20information\x20about\x20available\x20upgrades.\x20When\x20the\x20latest\x20version\x0aof\x20a\x20given\x20module\x20is\x20newer\x20than\x20the\x20current\x20one,\x20list\x20-u\x20sets\x20the\x20module's\x0aUpdate\x20field\x20to\x20information\x20about\x20the\x20newer\x20module.\x20The\x20module's\x20String\x0amethod\x20indicates\x20an\x20available\x20upgrade\x20by\x20formatting\x20the\x20newer\x20version\x20in\x0abrackets\x20after\x20the\x20current\x20version.\x20For\x20example,\x20go\x20list\x20-m\x20-u\x20all\x20might\x0aprint:

\x0a
example.com/main/module\x0agolang.org/x/text\x20v0.3.0\x20[v0.4.0]\x20=>\x20/tmp/text\x0arsc.io/pdf\x20v0.1.1\x20[v0.1.2]\x0a
\x0a

(For\x20tools,\x20go\x20list\x20-m\x20-u\x20-json\x20all\x20may\x20be\x20more\x20convenient\x20to\x20parse.)

\x0a

The\x20-versions\x20flag\x20causes\x20list\x20to\x20set\x20the\x20module's\x20Versions\x20field\x20to\x20a\x0alist\x20of\x20all\x20known\x20versions\x20of\x20that\x20module,\x20ordered\x20according\x20to\x20semantic\x0aversioning,\x20lowest\x20to\x20highest.\x20The\x20flag\x20also\x20changes\x20the\x20default\x20output\x20format\x0ato\x20display\x20the\x20module\x20path\x20followed\x20by\x20the\x20space-separated\x20version\x20list.

\x0a

The\x20template\x20function\x20module\x20takes\x20a\x20single\x20string\x20argument\x20that\x20must\x20be\x20a\x0amodule\x20path\x20or\x20query\x20and\x20returns\x20the\x20specified\x20module\x20as\x20a\x20Module\x20struct.\x20If\x0aan\x20error\x20occurs,\x20the\x20result\x20will\x20be\x20a\x20Module\x20struct\x20with\x20a\x20non-nil\x20Error\x0afield.

\x0ago\x20mod\x20download\x0a

Usage:

\x0a
go\x20mod\x20download\x20[-json]\x20[-x]\x20[modules]\x0a
\x0a

Example:

\x0a
$\x20go\x20mod\x20download\x0a$\x20go\x20mod\x20download\x20golang.org/x/mod@v0.2.0\x0a
\x0a

The\x20go\x20mod\x20download\x20command\x20downloads\x20the\x20named\x20modules\x20into\x20the\x20module\x0acache.\x20Arguments\x20can\x20be\x20module\x20paths\x20or\x20module\x0apatterns\x20selecting\x20dependencies\x20of\x20the\x20main\x20module\x20or\x20version\x0aqueries\x20of\x20the\x20form\x20path@version.\x20With\x20no\x20arguments,\x0adownload\x20applies\x20to\x20all\x20dependencies\x20of\x20the\x20main\x20module.

\x0a

The\x20go\x20command\x20will\x20automatically\x20download\x20modules\x20as\x20needed\x20during\x20ordinary\x0aexecution.\x20The\x20go\x20mod\x20download\x20command\x20is\x20useful\x20mainly\x20for\x20pre-filling\x20the\x0amodule\x20cache\x20or\x20for\x20loading\x20data\x20to\x20be\x20served\x20by\x20a\x20module\x0aproxy.

\x0a

By\x20default,\x20download\x20writes\x20nothing\x20to\x20standard\x20output.\x20It\x20prints\x20progress\x0amessages\x20and\x20errors\x20to\x20standard\x20error.

\x0a

The\x20-json\x20flag\x20causes\x20download\x20to\x20print\x20a\x20sequence\x20of\x20JSON\x20objects\x20to\x0astandard\x20output,\x20describing\x20each\x20downloaded\x20module\x20(or\x20failure),\x20corresponding\x0ato\x20this\x20Go\x20struct:

\x0a
type\x20Module\x20struct\x20{\x0a\x20\x20\x20\x20Path\x20\x20\x20\x20\x20string\x20//\x20module\x20path\x0a\x20\x20\x20\x20Version\x20\x20string\x20//\x20module\x20version\x0a\x20\x20\x20\x20Error\x20\x20\x20\x20string\x20//\x20error\x20loading\x20module\x0a\x20\x20\x20\x20Info\x20\x20\x20\x20\x20string\x20//\x20absolute\x20path\x20to\x20cached\x20.info\x20file\x0a\x20\x20\x20\x20GoMod\x20\x20\x20\x20string\x20//\x20absolute\x20path\x20to\x20cached\x20.mod\x20file\x0a\x20\x20\x20\x20Zip\x20\x20\x20\x20\x20\x20string\x20//\x20absolute\x20path\x20to\x20cached\x20.zip\x20file\x0a\x20\x20\x20\x20Dir\x20\x20\x20\x20\x20\x20string\x20//\x20absolute\x20path\x20to\x20cached\x20source\x20root\x20directory\x0a\x20\x20\x20\x20Sum\x20\x20\x20\x20\x20\x20string\x20//\x20checksum\x20for\x20path,\x20version\x20(as\x20in\x20go.sum)\x0a\x20\x20\x20\x20GoModSum\x20string\x20//\x20checksum\x20for\x20go.mod\x20(as\x20in\x20go.sum)\x0a}\x0a
\x0a

The\x20-x\x20flag\x20causes\x20download\x20to\x20print\x20the\x20commands\x20download\x20executes\x0ato\x20standard\x20error.

\x0ago\x20mod\x20edit\x0a

Usage:

\x0a
go\x20mod\x20edit\x20[editing\x20flags]\x20[-fmt|-print|-json]\x20[go.mod]\x0a
\x0a

Example:

\x0a
#\x20Add\x20a\x20replace\x20directive.\x0a$\x20go\x20mod\x20edit\x20-replace\x20example.com/a@v1.0.0=./a\x0a\x0a#\x20Remove\x20a\x20replace\x20directive.\x0a$\x20go\x20mod\x20edit\x20-dropreplace\x20example.com/a@v1.0.0\x0a\x0a#\x20Set\x20the\x20go\x20version,\x20add\x20a\x20requirement,\x20and\x20print\x20the\x20file\x0a#\x20instead\x20of\x20writing\x20it\x20to\x20disk.\x0a$\x20go\x20mod\x20edit\x20-go=1.14\x20-require=example.com/m@v1.0.0\x20-print\x0a\x0a#\x20Format\x20the\x20go.mod\x20file.\x0a$\x20go\x20mod\x20edit\x20-fmt\x0a\x0a#\x20Format\x20and\x20print\x20a\x20different\x20.mod\x20file.\x0a$\x20go\x20mod\x20edit\x20-print\x20tools.mod\x0a\x0a#\x20Print\x20a\x20JSON\x20representation\x20of\x20the\x20go.mod\x20file.\x0a$\x20go\x20mod\x20edit\x20-json\x0a
\x0a

The\x20go\x20mod\x20edit\x20command\x20provides\x20a\x20command-line\x20interface\x20for\x20editing\x20and\x0aformatting\x20go.mod\x20files,\x20for\x20use\x20primarily\x20by\x20tools\x20and\x20scripts.\x20go\x20mod\x20edit\x0areads\x20only\x20one\x20go.mod\x20file;\x20it\x20does\x20not\x20look\x20up\x20information\x20about\x20other\x0amodules.\x20By\x20default,\x20go\x20mod\x20edit\x20reads\x20and\x20writes\x20the\x20go.mod\x20file\x20of\x20the\x0amain\x20module,\x20but\x20a\x20different\x20target\x20file\x20can\x20be\x20specified\x20after\x20the\x20editing\x0aflags.

\x0a

The\x20editing\x20flags\x20specify\x20a\x20sequence\x20of\x20editing\x20operations.

\x0a
    \x0a
  • The\x20-module\x20flag\x20changes\x20the\x20module's\x20path\x20(the\x20go.mod\x20file's\x20module\x0aline).
  • \x0a
  • The\x20-go=version\x20flag\x20sets\x20the\x20expected\x20Go\x20language\x20version.
  • \x0a
  • The\x20-require=path@version\x20and\x20-droprequire=path\x20flags\x20add\x20and\x20drop\x20a\x0arequirement\x20on\x20the\x20given\x20module\x20path\x20and\x20version.\x20Note\x20that\x20-require\x0aoverrides\x20any\x20existing\x20requirements\x20on\x20path.\x20These\x20flags\x20are\x20mainly\x20for\x0atools\x20that\x20understand\x20the\x20module\x20graph.\x20Users\x20should\x20prefer\x20go\x20get\x20path@version\x20or\x20go\x20get\x20path@none,\x20which\x20make\x20other\x20go.mod\x20adjustments\x20as\x0aneeded\x20to\x20satisfy\x20constraints\x20imposed\x20by\x20other\x20modules.\x20See\x20go\x20get.
  • \x0a
  • The\x20-exclude=path@version\x20and\x20-dropexclude=path@version\x20flags\x20add\x20and\x20drop\x0aan\x20exclusion\x20for\x20the\x20given\x20module\x20path\x20and\x20version.\x20Note\x20that\x0a-exclude=path@version\x20is\x20a\x20no-op\x20if\x20that\x20exclusion\x20already\x20exists.
  • \x0a
  • The\x20-replace=old[@v]=new[@v]\x20flag\x20adds\x20a\x20replacement\x20of\x20the\x20given\x20module\x0apath\x20and\x20version\x20pair.\x20If\x20the\x20@v\x20in\x20old@v\x20is\x20omitted,\x20a\x20replacement\x0awithout\x20a\x20version\x20on\x20the\x20left\x20side\x20is\x20added,\x20which\x20applies\x20to\x20all\x20versions\x20of\x0athe\x20old\x20module\x20path.\x20If\x20the\x20@v\x20in\x20new@v\x20is\x20omitted,\x20the\x20new\x20path\x20should\x20be\x0aa\x20local\x20module\x20root\x20directory,\x20not\x20a\x20module\x20path.\x20Note\x20that\x20-replace\x0aoverrides\x20any\x20redundant\x20replacements\x20for\x20old[@v],\x20so\x20omitting\x20@v\x20will\x20drop\x0areplacements\x20for\x20specific\x20versions.
  • \x0a
  • The\x20-dropreplace=old[@v]\x20flag\x20drops\x20a\x20replacement\x20of\x20the\x20given\x20module\x20path\x0aand\x20version\x20pair.\x20If\x20the\x20@v\x20is\x20provided,\x20a\x20replacement\x20with\x20the\x20given\x0aversion\x20is\x20dropped.\x20An\x20existing\x20replacement\x20without\x20a\x20version\x20on\x20the\x20left\x20side\x0amay\x20still\x20replace\x20the\x20module.\x20If\x20the\x20@v\x20is\x20omitted,\x20a\x20replacement\x20without\x20a\x0aversion\x20is\x20dropped.
  • \x0a
\x0a

The\x20editing\x20flags\x20may\x20be\x20repeated.\x20The\x20changes\x20are\x20applied\x20in\x20the\x20order\x20given.

\x0a

go\x20mod\x20edit\x20has\x20additional\x20flags\x20that\x20control\x20its\x20output.

\x0a
    \x0a
  • The\x20-fmt\x20flag\x20reformats\x20the\x20go.mod\x20file\x20without\x20making\x20other\x20changes.\x0aThis\x20reformatting\x20is\x20also\x20implied\x20by\x20any\x20other\x20modifications\x20that\x20use\x20or\x0arewrite\x20the\x20go.mod\x20file.\x20The\x20only\x20time\x20this\x20flag\x20is\x20needed\x20is\x20if\x20no\x0aother\x20flags\x20are\x20specified,\x20as\x20in\x20go\x20mod\x20edit\x20-fmt.
  • \x0a
  • The\x20-print\x20flag\x20prints\x20the\x20final\x20go.mod\x20in\x20its\x20text\x20format\x20instead\x20of\x0awriting\x20it\x20back\x20to\x20disk.
  • \x0a
  • The\x20-json\x20flag\x20prints\x20the\x20final\x20go.mod\x20in\x20JSON\x20format\x20instead\x20of\x20writing\x0ait\x20back\x20to\x20disk\x20in\x20text\x20format.\x20The\x20JSON\x20output\x20corresponds\x20to\x20these\x20Go\x20types:
  • \x0a
\x0a
type\x20Module\x20struct\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20Path\x20string\x0a\x20\x20\x20\x20\x20\x20\x20\x20Version\x20string\x0a}\x0a\x0atype\x20GoMod\x20struct\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20Module\x20\x20Module\x0a\x20\x20\x20\x20\x20\x20\x20\x20Go\x20\x20\x20\x20\x20\x20string\x0a\x20\x20\x20\x20\x20\x20\x20\x20Require\x20[]Require\x0a\x20\x20\x20\x20\x20\x20\x20\x20Exclude\x20[]Module\x0a\x20\x20\x20\x20\x20\x20\x20\x20Replace\x20[]Replace\x0a}\x0a\x0atype\x20Require\x20struct\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20Path\x20string\x0a\x20\x20\x20\x20\x20\x20\x20\x20Version\x20string\x0a\x20\x20\x20\x20\x20\x20\x20\x20Indirect\x20bool\x0a}\x0a\x0atype\x20Replace\x20struct\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20Old\x20Module\x0a\x20\x20\x20\x20\x20\x20\x20\x20New\x20Module\x0a}\x0a
\x0a

Note\x20that\x20this\x20only\x20describes\x20the\x20go.mod\x20file\x20itself,\x20not\x20other\x20modules\x0areferred\x20to\x20indirectly.\x20For\x20the\x20full\x20set\x20of\x20modules\x20available\x20to\x20a\x20build,\x0ause\x20go\x20list\x20-m\x20-json\x20all.\x20See\x20go\x20list\x20-m.

\x0a

For\x20example,\x20a\x20tool\x20can\x20obtain\x20the\x20go.mod\x20file\x20as\x20a\x20data\x20structure\x20by\x0aparsing\x20the\x20output\x20of\x20go\x20mod\x20edit\x20-json\x20and\x20can\x20then\x20make\x20changes\x20by\x20invoking\x0ago\x20mod\x20edit\x20with\x20-require,\x20-exclude,\x20and\x20so\x20on.

\x0a

Tools\x20may\x20also\x20use\x20the\x20package\x0agolang.org/x/mod/modfile\x0ato\x20parse,\x20edit,\x20and\x20format\x20go.mod\x20files.

\x0ago\x20mod\x20init\x0a

Usage:

\x0a
go\x20mod\x20init\x20[module-path]\x0a
\x0a

Example:

\x0a
go\x20mod\x20init\x0ago\x20mod\x20init\x20example.com/m\x0a
\x0a

The\x20go\x20mod\x20init\x20command\x20initializes\x20and\x20writes\x20a\x20new\x20go.mod\x20file\x20in\x20the\x0acurrent\x20directory,\x20in\x20effect\x20creating\x20a\x20new\x20module\x20rooted\x20at\x20the\x20current\x0adirectory.\x20The\x20go.mod\x20file\x20must\x20not\x20already\x20exist.

\x0a

init\x20accepts\x20one\x20optional\x20argument,\x20the\x20module\x20path\x20for\x0athe\x20new\x20module.\x20See\x20Module\x20paths\x20for\x20instructions\x20on\x20choosing\x0aa\x20module\x20path.\x20If\x20the\x20module\x20path\x20argument\x20is\x20omitted,\x20init\x20will\x20attempt\x0ato\x20infer\x20the\x20module\x20path\x20using\x20import\x20comments\x20in\x20.go\x20files,\x20vendoring\x20tool\x0aconfiguration\x20files,\x20and\x20the\x20current\x20directory\x20(if\x20in\x20GOPATH).

\x0a

If\x20a\x20configuration\x20file\x20for\x20a\x20vendoring\x20tool\x20is\x20present,\x20init\x20will\x20attempt\x20to\x0aimport\x20module\x20requirements\x20from\x20it.\x20init\x20supports\x20the\x20following\x20configuration\x0afiles.

\x0a
    \x0a
  • GLOCKFILE\x20(Glock)
  • \x0a
  • Godeps/Godeps.json\x20(Godeps)
  • \x0a
  • Gopkg.lock\x20(dep)
  • \x0a
  • dependencies.tsv\x20(godeps)
  • \x0a
  • glide.lock\x20(glide)
  • \x0a
  • vendor.conf\x20(trash)
  • \x0a
  • vendor.yml\x20(govend)
  • \x0a
  • vendor/manifest\x20(gvt)
  • \x0a
  • vendor/vendor.json\x20(govendor)
  • \x0a
\x0a

Vendoring\x20tool\x20configuration\x20files\x20can't\x20always\x20be\x20translated\x20with\x20perfect\x0afidelity.\x20For\x20example,\x20if\x20multiple\x20packages\x20within\x20the\x20same\x20repository\x20are\x0aimported\x20at\x20different\x20versions,\x20and\x20the\x20repository\x20only\x20contains\x20one\x20module,\x20the\x0aimported\x20go.mod\x20can\x20only\x20require\x20the\x20module\x20at\x20one\x20version.\x20You\x20may\x20wish\x20to\x0arun\x20go\x20list\x20-m\x20all\x20to\x20check\x20all\x20versions\x20in\x20the\x20build\x0alist,\x20and\x20go\x20mod\x20tidy\x20to\x20add\x20missing\x0arequirements\x20and\x20to\x20drop\x20unused\x20requirements.

\x0ago\x20mod\x20tidy\x0a

Usage:

\x0a
go\x20mod\x20tidy\x20[-v]\x0a
\x0a

go\x20mod\x20tidy\x20ensures\x20that\x20the\x20go.mod\x20file\x20matches\x20the\x20source\x20code\x20in\x20the\x0amodule.\x20It\x20adds\x20any\x20missing\x20module\x20requirements\x20necessary\x20to\x20build\x20the\x20current\x0amodule's\x20packages\x20and\x20dependencies,\x20and\x20it\x20removes\x20requirements\x20on\x20modules\x20that\x0adon't\x20provide\x20any\x20relevant\x20packages.\x20It\x20also\x20adds\x20any\x20missing\x20entries\x20to\x0ago.sum\x20and\x20removes\x20unnecessary\x20entries.

\x0a

The\x20-v\x20flag\x20causes\x20go\x20mod\x20tidy\x20to\x20print\x20information\x20about\x20removed\x20modules\x0ato\x20standard\x20error.

\x0a

go\x20mod\x20tidy\x20works\x20by\x20loading\x20all\x20of\x20the\x20packages\x20in\x20the\x20main\x0amodule\x20and\x20all\x20of\x20the\x20packages\x20they\x20import,\x0arecursively.\x20This\x20includes\x20packages\x20imported\x20by\x20tests\x20(including\x20tests\x20in\x20other\x0amodules).\x20go\x20mod\x20tidy\x20acts\x20as\x20if\x20all\x20build\x20tags\x20are\x20enabled,\x20so\x20it\x20will\x0aconsider\x20platform-specific\x20source\x20files\x20and\x20files\x20that\x20require\x20custom\x20build\x0atags,\x20even\x20if\x20those\x20source\x20files\x20wouldn't\x20normally\x20be\x20built.\x20There\x20is\x20one\x0aexception:\x20the\x20ignore\x20build\x20tag\x20is\x20not\x20enabled,\x20so\x20a\x20file\x20with\x20the\x20build\x0aconstraint\x20//\x20+build\x20ignore\x20will\x20not\x20be\x20considered.\x20Note\x20that\x20go\x20mod\x20tidy\x0awill\x20not\x20consider\x20packages\x20in\x20the\x20main\x20module\x20in\x20directories\x20named\x20testdata\x20or\x0awith\x20names\x20that\x20start\x20with\x20.\x20or\x20_\x20unless\x20those\x20packages\x20are\x20explicitly\x0aimported\x20by\x20other\x20packages.

\x0a

Once\x20go\x20mod\x20tidy\x20has\x20loaded\x20this\x20set\x20of\x20packages,\x20it\x20ensures\x20that\x20each\x20module\x0athat\x20provides\x20one\x20or\x20more\x20packages\x20either\x20has\x20a\x20require\x20directive\x20in\x20the\x20main\x0amodule's\x20go.mod\x20file\x20or\x20is\x20required\x20by\x20another\x20required\x20module.\x20\x20go\x20mod\x20tidy\x0awill\x20add\x20a\x20requirement\x20on\x20the\x20latest\x20version\x20on\x20each\x20missing\x20module\x20(see\x0aVersion\x20queries\x20for\x20the\x20definition\x20of\x20the\x20latest\x0aversion).\x20go\x20mod\x20tidy\x20will\x20remove\x20require\x20directives\x20for\x20modules\x20that\x20don't\x0aprovide\x20any\x20packages\x20in\x20the\x20set\x20described\x20above.

\x0a

go\x20mod\x20tidy\x20may\x20also\x20add\x20or\x20remove\x20//\x20indirect\x20comments\x20on\x20require\x0adirectives.\x20An\x20//\x20indirect\x20comment\x20denotes\x20a\x20module\x20that\x20does\x20not\x20provide\x0apackages\x20imported\x20by\x20packages\x20in\x20the\x20main\x20module.\x20These\x20requirements\x20will\x20be\x0apresent\x20if\x20the\x20module\x20that\x20imports\x20packages\x20in\x20the\x20indirect\x20dependency\x20has\x0ano\x20go.mod\x20file.\x20They\x20may\x20also\x20be\x20present\x20if\x20the\x20indirect\x20dependency\x20is\x0arequired\x20at\x20a\x20higher\x20version\x20than\x20is\x20implied\x20by\x20the\x20module\x20graph;\x20this\x20usually\x0ahappens\x20after\x20running\x20a\x20command\x20like\x20go\x20get\x20-u\x20./....

\x0ago\x20mod\x20vendor\x0a

Usage:

\x0a
go\x20mod\x20vendor\x20[-v]\x0a
\x0a

The\x20go\x20mod\x20vendor\x20command\x20constructs\x20a\x20directory\x20named\x20vendor\x20in\x20the\x20main\x0amodule's\x20root\x20directory\x20that\x20contains\x20copies\x20of\x20all\x20packages\x0aneeded\x20to\x20support\x20builds\x20and\x20tests\x20of\x20packages\x20in\x20the\x20main\x20module.\x20Packages\x0athat\x20are\x20only\x20imported\x20by\x20tests\x20of\x20packages\x20outside\x20the\x20main\x20module\x20are\x20not\x0aincluded.\x20As\x20with\x20go\x20mod\x20tidy\x20and\x20other\x20module\x20commands,\x0abuild\x20constraints\x20except\x20for\x20ignore\x20are\x20not\x0aconsidered\x20when\x20constructing\x20the\x20vendor\x20directory.

\x0a

When\x20vendoring\x20is\x20enabled,\x20the\x20go\x20command\x20will\x20load\x20packages\x20from\x20the\x20vendor\x0adirectory\x20instead\x20of\x20downloading\x20modules\x20from\x20their\x20sources\x20into\x20the\x20module\x0acache\x20and\x20using\x20packages\x20those\x20downloaded\x20copies.\x20See\x20Vendoring\x0afor\x20more\x20information.

\x0a

go\x20mod\x20vendor\x20also\x20creates\x20the\x20file\x20vendor/modules.txt\x20that\x20contains\x20a\x20list\x0aof\x20vendored\x20packages\x20and\x20the\x20module\x20versions\x20they\x20were\x20copied\x20from.\x20When\x0avendoring\x20is\x20enabled,\x20this\x20manifest\x20is\x20used\x20as\x20a\x20source\x20of\x20module\x20version\x0ainformation,\x20as\x20reported\x20by\x20go\x20list\x20-m\x20and\x20go\x20version\x20-m.\x20When\x20the\x20go\x20command\x20reads\x20vendor/modules.txt,\x20it\x20checks\x0athat\x20the\x20module\x20versions\x20are\x20consistent\x20with\x20go.mod.\x20If\x20go.mod\x20changed\x20since\x0avendor/modules.txt\x20was\x20generated,\x20go\x20mod\x20vendor\x20should\x20be\x20run\x20again.

\x0a

Note\x20that\x20go\x20mod\x20vendor\x20removes\x20the\x20vendor\x20directory\x20if\x20it\x20exists\x20before\x0are-constructing\x20it.\x20Local\x20changes\x20should\x20not\x20be\x20made\x20to\x20vendored\x20packages.\x0aThe\x20go\x20command\x20does\x20not\x20check\x20that\x20packages\x20in\x20the\x20vendor\x20directory\x20have\x0anot\x20been\x20modified,\x20but\x20one\x20can\x20verify\x20the\x20integrity\x20of\x20the\x20vendor\x20directory\x0aby\x20running\x20go\x20mod\x20vendor\x20and\x20checking\x20that\x20no\x20changes\x20were\x20made.

\x0a

The\x20-v\x20flag\x20causes\x20go\x20mod\x20vendor\x20to\x20print\x20the\x20names\x20of\x20vendored\x20modules\x0aand\x20packages\x20to\x20standard\x20error.

\x0ago\x20mod\x20verify\x0a

Usage:

\x0a
go\x20mod\x20verify\x0a
\x0a

go\x20mod\x20verify\x20checks\x20that\x20dependencies\x20of\x20the\x20main\x20module\x0astored\x20in\x20the\x20module\x20cache\x20have\x20not\x20been\x20modified\x20since\x0athey\x20were\x20downloaded.\x20To\x20perform\x20this\x20check,\x20go\x20mod\x20verify\x20hashes\x20each\x0adownloaded\x20module\x20.zip\x20file\x20and\x20extracted\x20directory,\x20then\x0acompares\x20those\x20hashes\x20with\x20a\x20hash\x20recorded\x20when\x20the\x20module\x20was\x20first\x0adownloaded.\x20go\x20mod\x20verify\x20checks\x20each\x20module\x20in\x20the\x20build\x0alist\x20(which\x20may\x20be\x20printed\x20with\x20go\x20list\x20-m\x20all).

\x0a

If\x20all\x20the\x20modules\x20are\x20unmodified,\x20go\x20mod\x20verify\x20prints\x20"all\x20modules\x0averified".\x20Otherwise,\x20it\x20reports\x20which\x20modules\x20have\x20been\x20changed\x20and\x20exits\x20with\x0aa\x20non-zero\x20status.

\x0a

Note\x20that\x20all\x20module-aware\x20commands\x20verify\x20that\x20hashes\x20in\x20the\x20main\x20module's\x0ago.sum\x20file\x20match\x20hashes\x20recorded\x20for\x20modules\x20downloaded\x20into\x20the\x20module\x0acache.\x20If\x20a\x20hash\x20is\x20missing\x20from\x20go.sum\x20(for\x20example,\x20because\x20the\x20module\x20is\x0abeing\x20used\x20for\x20the\x20first\x20time),\x20the\x20go\x20command\x20verifies\x20its\x20hash\x20using\x20the\x0achecksum\x20database\x20(unless\x20the\x20module\x20path\x20is\x20matched\x20by\x0aGOPRIVATE\x20or\x20GONOSUMDB).\x20See\x20Authenticating\x20modules\x20for\x0adetails.

\x0a

In\x20contrast,\x20go\x20mod\x20verify\x20checks\x20that\x20module\x20.zip\x20files\x20and\x20their\x20extracted\x0adirectories\x20have\x20hashes\x20that\x20match\x20hashes\x20recorded\x20in\x20the\x20module\x20cache\x20when\x20they\x0awere\x20first\x20downloaded.\x20This\x20is\x20useful\x20for\x20detecting\x20changes\x20to\x20files\x20in\x20the\x0amodule\x20cache\x20after\x20a\x20module\x20has\x20been\x20downloaded\x20and\x20verified.\x20go\x20mod\x20verify\x0adoes\x20not\x20download\x20content\x20for\x20modules\x20not\x20in\x20the\x20cache,\x20and\x20it\x20does\x20not\x20use\x0ago.sum\x20files\x20to\x20verify\x20module\x20content.\x20However,\x20go\x20mod\x20verify\x20may\x20download\x0ago.mod\x20files\x20in\x20order\x20to\x20perform\x20minimal\x20version\x0aselection.\x20It\x20will\x20use\x20go.sum\x20to\x20verify\x20those\x0afiles,\x20and\x20it\x20may\x20add\x20go.sum\x20entries\x20for\x20missing\x20hashes.

\x0ago\x20version\x20-m\x0a

Usage:

\x0a
go\x20version\x20[-m]\x20[-v]\x20[file\x20...]\x0a
\x0a

Example:

\x0a
#\x20Print\x20Go\x20version\x20used\x20to\x20build\x20go.\x0a$\x20go\x20version\x0a\x0a#\x20Print\x20Go\x20version\x20used\x20to\x20build\x20a\x20specific\x20executable.\x0a$\x20go\x20version\x20~/go/bin/gopls\x0a\x0a#\x20Print\x20Go\x20version\x20and\x20module\x20versions\x20used\x20to\x20build\x20a\x20specific\x20executable.\x0a$\x20go\x20version\x20-m\x20~/go/bin/gopls\x0a\x0a#\x20Print\x20Go\x20version\x20and\x20module\x20versions\x20used\x20to\x20build\x20executables\x20in\x20a\x20directory.\x0a$\x20go\x20version\x20-m\x20~/go/bin/\x0a
\x0a

go\x20version\x20reports\x20the\x20Go\x20version\x20used\x20to\x20build\x20each\x20executable\x20file\x20named\x0aon\x20the\x20command\x20line.

\x0a

If\x20no\x20files\x20are\x20named\x20on\x20the\x20command\x20line,\x20go\x20version\x20prints\x20its\x20own\x20version\x0ainformation.

\x0a

If\x20a\x20directory\x20is\x20named,\x20go\x20version\x20walks\x20that\x20directory,\x20recursively,\x20looking\x0afor\x20recognized\x20Go\x20binaries\x20and\x20reporting\x20their\x20versions.\x20By\x20default,\x20go\x20version\x20does\x20not\x20report\x20unrecognized\x20files\x20found\x20during\x20a\x20directory\x20scan.\x20The\x0a-v\x20flag\x20causes\x20it\x20to\x20report\x20unrecognized\x20files.

\x0a

The\x20-m\x20flag\x20causes\x20go\x20version\x20to\x20print\x20each\x20executable's\x20embedded\x20module\x0aversion\x20information,\x20when\x20available.\x20For\x20each\x20executable,\x20go\x20version\x20-m\x20prints\x0aa\x20table\x20with\x20tab-separated\x20columns\x20like\x20the\x20one\x20below.

\x0a
$\x20go\x20version\x20-m\x20~/go/bin/goimports\x0a/home/jrgopher/go/bin/goimports:\x20go1.14.3\x0a\x20\x20\x20\x20\x20\x20\x20\x20path\x20\x20\x20\x20golang.org/x/tools/cmd/goimports\x0a\x20\x20\x20\x20\x20\x20\x20\x20mod\x20\x20\x20\x20\x20golang.org/x/tools\x20\x20\x20\x20\x20\x20v0.0.0-20200518203908-8018eb2c26ba\x20\x20\x20\x20\x20\x20h1:0Lcy64USfQQL6GAJma8BdHCgeofcchQj+Z7j0SXYAzU=\x0a\x20\x20\x20\x20\x20\x20\x20\x20dep\x20\x20\x20\x20\x20golang.org/x/mod\x20\x20\x20\x20\x20\x20\x20\x20v0.2.0\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20h1:KU7oHjnv3XNWfa5COkzUifxZmxp1TyI7ImMXqFxLwvQ=\x0a\x20\x20\x20\x20\x20\x20\x20\x20dep\x20\x20\x20\x20\x20golang.org/x/xerrors\x20\x20\x20\x20v0.0.0-20191204190536-9bdfabe68543\x20\x20\x20\x20\x20\x20h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=\x0a
\x0a

The\x20format\x20of\x20the\x20table\x20may\x20change\x20in\x20the\x20future.\x20The\x20same\x20information\x20may\x20be\x0aobtained\x20from\x0aruntime/debug.ReadBuildInfo.

\x0a

The\x20meaning\x20of\x20each\x20row\x20in\x20the\x20table\x20is\x20determined\x20by\x20the\x20word\x20in\x20the\x20first\x0acolumn.

\x0a
    \x0a
  • path:\x20the\x20path\x20of\x20the\x20main\x20package\x20used\x20to\x20build\x20the\x20executable.
  • \x0a
  • mod:\x20the\x20module\x20containing\x20the\x20main\x20package.\x20The\x20columns\x20are\x20the\x0amodule\x20path,\x20version,\x20and\x20sum,\x20respectively.\x20The\x20main\x0amodule\x20has\x20the\x20version\x20(devel)\x20and\x20no\x20sum.
  • \x0a
  • dep:\x20a\x20module\x20that\x20provided\x20one\x20or\x20more\x20packages\x20linked\x20into\x20the\x0aexecutable.\x20Same\x20format\x20as\x20mod.
  • \x0a
  • =>:\x20a\x20replacement\x20for\x20the\x20module\x20on\x20the\x20previous\x0aline.\x20If\x20the\x20replacement\x20is\x20a\x20local\x20directory,\x20only\x20the\x20directory\x20path\x20is\x0alisted\x20(no\x20version\x20or\x20sum).\x20If\x20the\x20replacement\x20is\x20a\x20module\x20version,\x20the\x20path,\x0aversion,\x20and\x20sum\x20are\x20listed,\x20as\x20with\x20mod\x20and\x20dep.\x20A\x20replaced\x20module\x20has\x0ano\x20sum.
  • \x0a
\x0ago\x20clean\x20-modcache\x0a

Usage:

\x0a
go\x20clean\x20[-modcache]\x0a
\x0a

The\x20-modcache\x20flag\x20causes\x20go\x20clean\x20to\x20remove\x20the\x20entire\x0amodule\x20cache,\x20including\x20unpacked\x20source\x20code\x20of\x20versioned\x0adependencies.

\x0a

This\x20is\x20usually\x20the\x20best\x20way\x20to\x20remove\x20the\x20module\x20cache.\x20By\x20default,\x20most\x20files\x0aand\x20directories\x20in\x20the\x20module\x20cache\x20are\x20read-only\x20to\x20prevent\x20tests\x20and\x20editors\x0afrom\x20unintentionally\x20changing\x20files\x20after\x20they've\x20been\x0aauthenticated.\x20Unfortunately,\x20this\x20causes\x20commands\x20like\x0arm\x20-r\x20to\x20fail,\x20since\x20files\x20can't\x20be\x20removed\x20without\x20first\x20making\x20their\x20parent\x0adirectories\x20writable.

\x0a

The\x20-modcacherw\x20flag\x20(accepted\x20by\x20go\x20build\x20and\x0aother\x20module-aware\x20commands)\x20causes\x20new\x20directories\x20in\x20the\x20module\x20cache\x20to\x0abe\x20writable.\x20To\x20pass\x20-modcacherw\x20to\x20all\x20module-aware\x20commands,\x20add\x20it\x20to\x20the\x0aGOFLAGS\x20variable.\x20GOFLAGS\x20may\x20be\x20set\x20in\x20the\x20environment\x20or\x20with\x20go\x20env\x20-w.\x20For\x0aexample,\x20the\x20command\x20below\x20sets\x20it\x20permanently:

\x0a
go\x20env\x20-w\x20GOFLAGS=-modcacherw\x0a
\x0a

-modcacherw\x20should\x20be\x20used\x20with\x20caution;\x20developers\x20should\x20be\x20careful\x20not\x0ato\x20make\x20changes\x20to\x20files\x20in\x20the\x20module\x20cache.\x20go\x20mod\x20verify\x0amay\x20be\x20used\x20to\x20check\x20that\x20files\x20in\x20the\x20cache\x20match\x20hashes\x20in\x20the\x20main\x20module's\x0ago.sum\x20file.

\x0aVersion\x20queries\x0a

Several\x20commands\x20allow\x20you\x20to\x20specify\x20a\x20version\x20of\x20a\x20module\x20using\x20a\x20version\x0aquery,\x20which\x20appears\x20after\x20an\x20@\x20character\x20following\x20a\x20module\x20or\x20package\x20path\x0aon\x20the\x20command\x20line.

\x0a

Examples:

\x0a
go\x20get\x20example.com/m@latest\x0ago\x20mod\x20download\x20example.com/m@master\x0ago\x20list\x20-m\x20-json\x20example.com/m@e3702bed2\x0a
\x0a

A\x20version\x20query\x20may\x20be\x20one\x20of\x20the\x20following:

\x0a
    \x0a
  • A\x20fully-specified\x20semantic\x20version,\x20such\x20as\x20v1.2.3,\x20which\x20selects\x20a\x0aspecific\x20version.\x20See\x20Versions\x20for\x20syntax.
  • \x0a
  • A\x20semantic\x20version\x20prefix,\x20such\x20as\x20v1\x20or\x20v1.2,\x20which\x20selects\x20the\x20highest\x0aavailable\x20version\x20with\x20that\x20prefix.
  • \x0a
  • A\x20semantic\x20version\x20comparison,\x20such\x20as\x20<v1.2.3\x20or\x20>=v1.5.6,\x20which\x20selects\x0athe\x20nearest\x20available\x20version\x20to\x20the\x20comparison\x20target\x20(the\x20lowest\x20version\x0afor\x20>\x20and\x20>=,\x20and\x20the\x20highest\x20version\x20for\x20<\x20and\x20<=).
  • \x0a
  • A\x20revision\x20identifier\x20for\x20the\x20underlying\x20source\x20repository,\x20such\x20as\x20a\x20commit\x0ahash\x20prefix,\x20revision\x20tag,\x20or\x20branch\x20name.\x20If\x20the\x20revision\x20is\x20tagged\x20with\x20a\x0asemantic\x20version,\x20this\x20query\x20selects\x20that\x20version.\x20Otherwise,\x20this\x20query\x0aselects\x20a\x20pseudo-version\x20for\x20the\x20underlying\x0acommit.\x20Note\x20that\x20branches\x20and\x20tags\x20with\x20names\x20matched\x20by\x20other\x20version\x0aqueries\x20cannot\x20be\x20selected\x20this\x20way.\x20For\x20example,\x20the\x20query\x20v2\x20selects\x20the\x0alatest\x20version\x20starting\x20with\x20v2,\x20not\x20the\x20branch\x20named\x20v2.
  • \x0a
  • The\x20string\x20latest,\x20which\x20selects\x20the\x20highest\x20available\x20release\x20version.\x20If\x0athere\x20are\x20no\x20release\x20versions,\x20latest\x20selects\x20the\x20highest\x20pre-release\x0aversion.\x20\x20If\x20there\x20no\x20tagged\x20versions,\x20latest\x20selects\x20a\x20pseudo-version\x20for\x0athe\x20commit\x20at\x20the\x20tip\x20of\x20the\x20repository's\x20default\x20branch.
  • \x0a
  • The\x20string\x20upgrade,\x20which\x20is\x20like\x20latest\x20except\x20that\x20if\x20the\x20module\x20is\x0acurrently\x20required\x20at\x20a\x20higher\x20version\x20than\x20the\x20version\x20latest\x20would\x20select\x0a(for\x20example,\x20a\x20pre-release),\x20upgrade\x20will\x20select\x20the\x20current\x20version.
  • \x0a
  • The\x20string\x20patch,\x20which\x20selects\x20the\x20latest\x20available\x20version\x20with\x20the\x20same\x0amajor\x20and\x20minor\x20version\x20numbers\x20as\x20the\x20currently\x20required\x20version.\x20If\x20no\x0aversion\x20is\x20currently\x20required,\x20patch\x20is\x20equivalent\x20to\x20latest.
  • \x0a
\x0a

Except\x20for\x20queries\x20for\x20specific\x20named\x20versions\x20or\x20revisions,\x20all\x20queries\x0aconsider\x20available\x20versions\x20reported\x20by\x20go\x20list\x20-m\x20-versions\x20(see\x20go\x20list\x20-m).\x20This\x20list\x20contains\x20only\x20tagged\x20versions,\x20not\x20pseudo-versions.\x0aModule\x20versions\x20disallowed\x20by\x20exclude\x20directives\x20in\x0athe\x20main\x20module's\x20go.mod\x20file\x20are\x20not\x20considered.

\x0a

Release\x20versions\x20are\x20preferred\x20over\x20pre-release\x0aversions.\x20For\x20example,\x20if\x20versions\x20v1.2.2\x20and\x20v1.2.3-pre\x20are\x20available,\x20the\x0alatest\x20query\x20will\x20select\x20v1.2.2,\x20even\x20though\x20v1.2.3-pre\x20is\x20higher.\x20The\x0a<v1.2.4\x20query\x20would\x20also\x20select\x20v1.2.2,\x20even\x20though\x20v1.2.3-pre\x20is\x20closer\x0ato\x20v1.2.4.\x20If\x20no\x20release\x20or\x20pre-release\x20version\x20is\x20available,\x20the\x20latest,\x0aupgrade,\x20and\x20patch\x20queries\x20will\x20select\x20a\x20pseudo-version\x20for\x20the\x20commit\x0aat\x20the\x20tip\x20of\x20the\x20repository's\x20default\x20branch.\x20Other\x20queries\x20will\x20report\x0aan\x20error.

\x0aModule\x20commands\x20outside\x20a\x20module\x0a

Module-aware\x20Go\x20commands\x20normally\x20run\x20in\x20the\x20context\x20of\x20a\x20main\x0amodule\x20defined\x20by\x20a\x20go.mod\x20file\x20in\x20the\x20working\x20directory\x0aor\x20a\x20parent\x20directory.\x20Some\x20commands\x20may\x20be\x20run\x20in\x20module-aware\x20mode\x20without\x20a\x0ago.mod\x20file\x20by\x20setting\x20the\x20GO111MODULE\x20environment\x20variable\x20to\x20on.\x0aMost\x20commands\x20work\x20differently\x20when\x20no\x20go.mod\x20file\x20is\x20present.

\x0a

See\x20Module-aware\x20commands\x20for\x20information\x20on\x20enabling\x20and\x0adisabling\x20module-aware\x20mode.

\x0a\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20Command\x0a\x20\x20\x20\x20\x20\x20Behavior\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20build
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20doc
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20fix
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20fmt
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20generate
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20install
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20list
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20run
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20test
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20vet\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Only\x20packages\x20in\x20the\x20standard\x20library\x20and\x20packages\x20specified\x20as\x0a\x20\x20\x20\x20\x20\x20\x20\x20.go\x20files\x20on\x20the\x20command\x20line\x20can\x20be\x20loaded,\x20imported,\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20built.\x20Packages\x20from\x20other\x20modules\x20cannot\x20be\x20built,\x20since\x20there\x20is\x20no\x0a\x20\x20\x20\x20\x20\x20\x20\x20place\x20to\x20record\x20module\x20requirements\x20and\x20ensure\x20deterministic\x20builds.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20go\x20get\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Packages\x20and\x20executables\x20may\x20be\x20built\x20and\x20installed\x20as\x20usual.\x20Note\x20that\x0a\x20\x20\x20\x20\x20\x20\x20\x20there\x20is\x20no\x20main\x20module\x20when\x20go\x20get\x20is\x20run\x20without\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20go.mod\x20file,\x20so\x20replace\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20exclude\x20directives\x20are\x20not\x20applied.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20go\x20list\x20-m\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Explicit\x20version\x20queries\x20are\x20required\x0a\x20\x20\x20\x20\x20\x20\x20\x20for\x20most\x20arguments,\x20except\x20when\x20the\x20-versions\x20flag\x20is\x20used.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20go\x20mod\x20download\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Explicit\x20version\x20queries\x20are\x20required\x0a\x20\x20\x20\x20\x20\x20\x20\x20for\x20most\x20arguments.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20go\x20mod\x20edit\x0a\x20\x20\x20\x20\x20\x20An\x20explicit\x20file\x20argument\x20is\x20required.\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20mod\x20graph
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20mod\x20tidy
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20mod\x20vendor
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20mod\x20verify
\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20mod\x20why\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20These\x20commands\x20require\x20a\x20go.mod\x20file\x20and\x20will\x20report\x0a\x20\x20\x20\x20\x20\x20\x20\x20an\x20error\x20if\x20one\x20is\x20not\x20present.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x0aModule\x20proxies\x0aGOPROXY\x20protocol\x0a

A\x20module\x20proxy\x20is\x20an\x20HTTP\x20server\x20that\x20can\x20respond\x20to\x20GET\x20requests\x0afor\x20paths\x20specified\x20below.\x20The\x20requests\x20have\x20no\x20query\x20parameters,\x20and\x20no\x0aspecific\x20headers\x20are\x20required,\x20so\x20even\x20a\x20site\x20serving\x20from\x20a\x20fixed\x20file\x20system\x0a(including\x20a\x20file://\x20URL)\x20can\x20be\x20a\x20module\x20proxy.

\x0a

Successful\x20HTTP\x20responses\x20must\x20have\x20the\x20status\x20code\x20200\x20(OK).\x20Redirects\x20(3xx)\x0aare\x20followed.\x20Responses\x20with\x20status\x20codes\x204xx\x20and\x205xx\x20are\x20treated\x20as\x20errors.\x0aThe\x20error\x20codes\x20404\x20(Not\x20Found)\x20and\x20410\x20(Gone)\x20indicate\x20that\x20the\x0arequested\x20module\x20or\x20version\x20is\x20not\x20available\x20on\x20the\x20proxy,\x20but\x20it\x20may\x20be\x20found\x0aelsewhere.\x20Error\x20responses\x20should\x20have\x20content\x20type\x20text/plain\x20with\x0acharset\x20either\x20utf-8\x20or\x20us-ascii.

\x0a

The\x20go\x20command\x20may\x20be\x20configured\x20to\x20contact\x20proxies\x20or\x20source\x20control\x20servers\x0ausing\x20the\x20GOPROXY\x20environment\x20variable,\x20which\x20accepts\x20a\x20list\x20of\x20proxy\x20URLs.\x0aThe\x20list\x20may\x20include\x20the\x20keywords\x20direct\x20or\x20off\x20(see\x20Environment\x0avariables\x20for\x20details).\x20List\x20elements\x20may\x20be\x20separated\x0aby\x20commas\x20(,)\x20or\x20pipes\x20(|),\x20which\x20determine\x20error\x20fallback\x20behavior.\x20When\x20a\x0aURL\x20is\x20followed\x20by\x20a\x20comma,\x20the\x20go\x20command\x20falls\x20back\x20to\x20later\x20sources\x20only\x0aafter\x20a\x20404\x20(Not\x20Found)\x20or\x20410\x20(Gone)\x20response.\x20When\x20a\x20URL\x20is\x20followed\x20by\x20a\x0apipe,\x20the\x20go\x20command\x20falls\x20back\x20to\x20later\x20sources\x20after\x20any\x20error,\x20including\x0anon-HTTP\x20errors\x20such\x20as\x20timeouts.\x20This\x20error\x20handling\x20behavior\x20lets\x20a\x20proxy\x20act\x0aas\x20a\x20gatekeeper\x20for\x20unknown\x20modules.\x20For\x20example,\x20a\x20proxy\x20could\x20respond\x20with\x0aerror\x20403\x20(Forbidden)\x20for\x20modules\x20not\x20on\x20an\x20approved\x20list\x20(see\x20Private\x20proxy\x0aserving\x20private\x20modules).

\x0a

The\x20table\x20below\x20specifies\x20queries\x20that\x20a\x20module\x20proxy\x20must\x20respond\x20to.\x20For\x20each\x0apath,\x20$base\x20is\x20the\x20path\x20portion\x20of\x20a\x20proxy\x20URL,$module\x20is\x20a\x20module\x20path,\x20and\x0a$version\x20is\x20a\x20version.\x20For\x20example,\x20if\x20the\x20proxy\x20URL\x20is\x0ahttps://example.com/mod,\x20and\x20the\x20client\x20is\x20requesting\x20the\x20go.mod\x20file\x20for\x0athe\x20module\x20golang.org/x/text\x20at\x20version\x20v0.3.2,\x20the\x20client\x20would\x20send\x20a\x0aGET\x20request\x20for\x20https://example.com/mod/golang.org/x/text/@v/v0.3.2.mod.

\x0a

To\x20avoid\x20ambiguity\x20when\x20serving\x20from\x20case-insensitive\x20file\x20systems,\x0athe\x20$module\x20and\x20$version\x20elements\x20are\x20case-encoded\x20by\x20replacing\x20every\x0auppercase\x20letter\x20with\x20an\x20exclamation\x20mark\x20followed\x20by\x20the\x20corresponding\x0alower-case\x20letter.\x20This\x20allows\x20modules\x20example.com/M\x20and\x20example.com/m\x20to\x0aboth\x20be\x20stored\x20on\x20disk,\x20since\x20the\x20former\x20is\x20encoded\x20as\x20example.com/!m.

\x0a\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20Path\x0a\x20\x20\x20\x20\x20\x20Description\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$base/$module/@v/list\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Returns\x20a\x20list\x20of\x20known\x20versions\x20of\x20the\x20given\x20module\x20in\x20plain\x20text,\x20one\x0a\x20\x20\x20\x20\x20\x20\x20\x20per\x20line.\x20This\x20list\x20should\x20not\x20include\x20pseudo-versions.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$base/$module/@v/$version.info\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Returns\x20JSON-formatted\x20metadata\x20about\x20a\x20specific\x20version\x20of\x20a\x20module.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20The\x20response\x20must\x20be\x20a\x20JSON\x20object\x20that\x20corresponds\x20to\x20the\x20Go\x20data\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20structure\x20below:\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20
\x0atype\x20Info\x20struct\x20{\x0a\x20\x20\x20\x20Version\x20string\x20\x20\x20\x20//\x20version\x20string\x0a\x20\x20\x20\x20Time\x20\x20\x20\x20time.Time\x20//\x20commit\x20time\x0a}\x0a
\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20The\x20Version\x20field\x20is\x20required\x20and\x20must\x20contain\x20a\x20valid,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20canonical\x20version\x20(see\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Versions).\x20The\x20$version\x20in\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20request\x20path\x20does\x20not\x20need\x20to\x20be\x20the\x20same\x20version\x20or\x20even\x20a\x20valid\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20version;\x20this\x20endpoint\x20may\x20be\x20used\x20to\x20find\x20versions\x20for\x20branch\x20names\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20or\x20revision\x20identifiers.\x20However,\x20if\x20$version\x20is\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20canonical\x20version\x20with\x20a\x20major\x20version\x20compatible\x20with\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20$module,\x20the\x20Version\x20field\x20in\x20a\x20successful\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20response\x20must\x20be\x20the\x20same.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20The\x20Time\x20field\x20is\x20optional.\x20If\x20present,\x20it\x20must\x20be\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20string\x20in\x20RFC\x203339\x20format.\x20It\x20indicates\x20the\x20time\x20when\x20the\x20version\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20was\x20created.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20More\x20fields\x20may\x20be\x20added\x20in\x20the\x20future,\x20so\x20other\x20names\x20are\x20reserved.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$base/$module/@v/$version.mod\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Returns\x20the\x20go.mod\x20file\x20for\x20a\x20specific\x20version\x20of\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20module.\x20If\x20the\x20module\x20does\x20not\x20have\x20a\x20go.mod\x20file\x20at\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20requested\x20version,\x20a\x20file\x20containing\x20only\x20a\x20module\x0a\x20\x20\x20\x20\x20\x20\x20\x20statement\x20with\x20the\x20requested\x20module\x20path\x20must\x20be\x20returned.\x20Otherwise,\x0a\x20\x20\x20\x20\x20\x20\x20\x20the\x20original,\x20unmodified\x20go.mod\x20file\x20must\x20be\x20returned.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$base/$module/@v/$version.zip\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Returns\x20a\x20zip\x20file\x20containing\x20the\x20contents\x20of\x20a\x20specific\x20version\x20of\x0a\x20\x20\x20\x20\x20\x20\x20\x20a\x20module.\x20See\x20Module\x20zip\x20files\x20for\x20details\x0a\x20\x20\x20\x20\x20\x20\x20\x20on\x20how\x20this\x20zip\x20file\x20must\x20be\x20formatted.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$base/$module/@latest\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Returns\x20JSON-formatted\x20metadata\x20about\x20the\x20latest\x20known\x20version\x20of\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20module\x20in\x20the\x20same\x20format\x20as\x0a\x20\x20\x20\x20\x20\x20\x20\x20$base/$module/@v/$version.info.\x20The\x20latest\x20version\x20should\x0a\x20\x20\x20\x20\x20\x20\x20\x20be\x20the\x20version\x20of\x20the\x20module\x20that\x20the\x20go\x20command\x20should\x20use\x0a\x20\x20\x20\x20\x20\x20\x20\x20if\x20$base/$module/@v/list\x20is\x20empty\x20or\x20no\x20listed\x20version\x20is\x0a\x20\x20\x20\x20\x20\x20\x20\x20suitable.\x20This\x20endpoint\x20is\x20optional,\x20and\x20module\x20proxies\x20are\x20not\x20required\x0a\x20\x20\x20\x20\x20\x20\x20\x20to\x20implement\x20it.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x0a

When\x20resolving\x20the\x20latest\x20version\x20of\x20a\x20module,\x20the\x20go\x20command\x20will\x20request\x0a$base/$module/@v/list,\x20then,\x20if\x20no\x20suitable\x20versions\x20are\x20found,\x0a$base/$module/@latest.\x20The\x20go\x20command\x20prefers,\x20in\x20order:\x20the\x20semantically\x0ahighest\x20release\x20version,\x20the\x20semantically\x20highest\x20pre-release\x20version,\x20and\x20the\x0achronologically\x20most\x20recent\x20pseudo-version.\x20In\x20Go\x201.12\x20and\x20earlier,\x20the\x20go\x0acommand\x20considered\x20pseudo-versions\x20in\x20$base/$module/@v/list\x20to\x20be\x20pre-release\x0aversions,\x20but\x20this\x20is\x20no\x20longer\x20true\x20since\x20Go\x201.13.

\x0a

A\x20module\x20proxy\x20must\x20always\x20serve\x20the\x20same\x20content\x20for\x20successful\x0aresponses\x20for\x20$base/$module/$version.mod\x20and\x20$base/$module/$version.zip\x0aqueries.\x20This\x20content\x20is\x20cryptographically\x20authenticated\x0ausing\x20go.sum\x20files\x20and,\x20by\x20default,\x20the\x0achecksum\x20database.

\x0a

The\x20go\x20command\x20caches\x20most\x20content\x20it\x20downloads\x20from\x20module\x20proxies\x20in\x20its\x0amodule\x20cache\x20in\x20$GOPATH/pkg/mod/cache/download.\x20Even\x20when\x20downloading\x20directly\x0afrom\x20version\x20control\x20systems,\x20the\x20go\x20command\x20synthesizes\x20explicit\x20info,\x0amod,\x20and\x20zip\x20files\x20and\x20stores\x20them\x20in\x20this\x20directory,\x20the\x20same\x20as\x20if\x20it\x20had\x0adownloaded\x20them\x20directly\x20from\x20a\x20proxy.\x20The\x20cache\x20layout\x20is\x20the\x20same\x20as\x20the\x20proxy\x0aURL\x20space,\x20so\x20serving\x20$GOPATH/pkg/mod/cache/download\x20at\x20(or\x20copying\x20it\x20to)\x0ahttps://example.com/proxy\x20would\x20let\x20users\x20access\x20cached\x20module\x20versions\x20by\x0asetting\x20GOPROXY\x20to\x20https://example.com/proxy.

\x0aCommunicating\x20with\x20proxies\x0a

The\x20go\x20command\x20may\x20download\x20module\x20source\x20code\x20and\x20metadata\x20from\x20a\x20module\x0aproxy.\x20The\x20GOPROXY\x20environment\x0avariable\x20may\x20be\x20used\x20to\x20configure\x20which\x20proxies\x20the\x0ago\x20command\x20may\x20connect\x20to\x20and\x20whether\x20it\x20may\x20communicate\x20directly\x20with\x0aversion\x20control\x20systems.\x20Downloaded\x20module\x20data\x20is\x20saved\x20in\x20the\x20module\x0acache.\x20The\x20go\x20command\x20will\x20only\x20contact\x20a\x20proxy\x20when\x20it\x0aneeds\x20information\x20not\x20already\x20in\x20the\x20cache.

\x0a

The\x20GOPROXY\x20protocol\x20section\x20describes\x20requests\x20that\x0amay\x20be\x20sent\x20to\x20a\x20GOPROXY\x20server.\x20However,\x20it's\x20also\x20helpful\x20to\x20understand\x0awhen\x20the\x20go\x20command\x20makes\x20these\x20requests.\x20For\x20example,\x20go\x20build\x20follows\x0athe\x20procedure\x20below:

\x0a
    \x0a
  • Compute\x20the\x20build\x20list\x20by\x20reading\x20go.mod\x0afiles\x20and\x20performing\x20minimal\x20version\x20selection\x0a(MVS).
  • \x0a
  • Read\x20the\x20packages\x20named\x20on\x20the\x20command\x20line\x20and\x20the\x20packages\x20they\x20import.
  • \x0a
  • If\x20a\x20package\x20is\x20not\x20provided\x20by\x20any\x20module\x20in\x20the\x20build\x20list,\x20find\x20a\x20module\x0athat\x20provides\x20it.\x20Add\x20a\x20module\x20requirement\x20on\x20its\x20latest\x20version\x20to\x20go.mod,\x0aand\x20start\x20over.
  • \x0a
  • Build\x20packages\x20after\x20everything\x20is\x20loaded.
  • \x0a
\x0a

When\x20the\x20go\x20command\x20computes\x20the\x20build\x20list,\x20it\x20loads\x20the\x20go.mod\x20file\x20for\x0aeach\x20module\x20in\x20the\x20module\x20graph.\x20If\x20a\x20go.mod\x20file\x20is\x20not\x0ain\x20the\x20cache,\x20the\x20go\x20command\x20will\x20download\x20it\x20from\x20the\x20proxy\x20using\x20a\x0a$module/@v/$version.mod\x20request\x20(where\x20$module\x20is\x20the\x20module\x20path\x20and\x0a$version\x20is\x20the\x20version).\x20These\x20requests\x20can\x20be\x20tested\x20with\x20a\x20tool\x20like\x0acurl.\x20For\x20example,\x20the\x20command\x20below\x20downloads\x20the\x20go.mod\x20file\x20for\x0agolang.org/x/mod\x20at\x20version\x20v0.2.0:

\x0a
$\x20curl\x20https://proxy.golang.org/golang.org/x/mod/@v/v0.2.0.mod\x0amodule\x20golang.org/x/mod\x0a\x0ago\x201.12\x0a\x0arequire\x20(\x0a\x09golang.org/x/crypto\x20v0.0.0-20191011191535-87dc89f01550\x0a\x09golang.org/x/tools\x20v0.0.0-20191119224855-298f0cb1881e\x0a\x09golang.org/x/xerrors\x20v0.0.0-20191011141410-1b5146add898\x0a)\x0a
\x0a

In\x20order\x20to\x20load\x20a\x20package,\x20the\x20go\x20command\x20needs\x20the\x20source\x20code\x20for\x20the\x0amodule\x20that\x20provides\x20it.\x20Module\x20source\x20code\x20is\x20distributed\x20in\x20.zip\x20files\x20which\x0aare\x20extracted\x20into\x20the\x20module\x20cache.\x20If\x20a\x20module\x20.zip\x20is\x20not\x20in\x20the\x20cache,\x0athe\x20go\x20command\x20will\x20download\x20it\x20using\x20a\x20$module/@v/$version.zip\x20request.

\x0a
$\x20curl\x20-O\x20https://proxy.golang.org/golang.org/x/mod/@v/v0.2.0.zip\x0a$\x20unzip\x20-l\x20v0.2.0.zip\x20|\x20head\x0aArchive:\x20\x20v0.2.0.zip\x0a\x20\x20Length\x20\x20\x20\x20\x20\x20Date\x20\x20\x20\x20Time\x20\x20\x20\x20Name\x0a---------\x20\x20----------\x20-----\x20\x20\x20----\x0a\x20\x20\x20\x20\x201479\x20\x2000-00-1980\x2000:00\x20\x20\x20golang.org/x/mod@v0.2.0/LICENSE\x0a\x20\x20\x20\x20\x201303\x20\x2000-00-1980\x2000:00\x20\x20\x20golang.org/x/mod@v0.2.0/PATENTS\x0a\x20\x20\x20\x20\x20\x20559\x20\x2000-00-1980\x2000:00\x20\x20\x20golang.org/x/mod@v0.2.0/README\x0a\x20\x20\x20\x20\x20\x20\x2021\x20\x2000-00-1980\x2000:00\x20\x20\x20golang.org/x/mod@v0.2.0/codereview.cfg\x0a\x20\x20\x20\x20\x20\x20214\x20\x2000-00-1980\x2000:00\x20\x20\x20golang.org/x/mod@v0.2.0/go.mod\x0a\x20\x20\x20\x20\x201476\x20\x2000-00-1980\x2000:00\x20\x20\x20golang.org/x/mod@v0.2.0/go.sum\x0a\x20\x20\x20\x20\x205224\x20\x2000-00-1980\x2000:00\x20\x20\x20golang.org/x/mod@v0.2.0/gosumcheck/main.go\x0a
\x0a

Note\x20that\x20.mod\x20and\x20.zip\x20requests\x20are\x20separate,\x20even\x20though\x20go.mod\x20files\x0aare\x20usually\x20contained\x20within\x20.zip\x20files.\x20The\x20go\x20command\x20may\x20need\x20to\x20download\x0ago.mod\x20files\x20for\x20many\x20different\x20modules,\x20and\x20.mod\x20files\x20are\x20much\x20smaller\x0athan\x20.zip\x20files.\x20Additionally,\x20if\x20a\x20Go\x20project\x20does\x20not\x20have\x20a\x20go.mod\x20file,\x0athe\x20proxy\x20will\x20serve\x20a\x20synthetic\x20go.mod\x20file\x20that\x20only\x20contains\x20a\x20module\x0adirective.\x20Synthetic\x20go.mod\x20files\x20are\x20generated\x20by\x20the\x20go\x0acommand\x20when\x20downloading\x20from\x20a\x20version\x20control\x0asystem.

\x0a

If\x20the\x20go\x20command\x20needs\x20to\x20load\x20a\x20package\x20not\x20provided\x20by\x20any\x20module\x20in\x20the\x0abuild\x20list,\x20it\x20will\x20attempt\x20to\x20find\x20a\x20new\x20module\x20that\x20provides\x20it.\x20The\x20section\x0aResolving\x20a\x20package\x20to\x20a\x20module\x20describes\x20this\x20process.\x20In\x0asummary,\x20the\x20go\x20command\x20requests\x20information\x20about\x20the\x20latest\x20version\x20of\x20each\x0amodule\x20path\x20that\x20could\x20possibly\x20contain\x20the\x20package.\x20For\x20example,\x20for\x20the\x0apackage\x20golang.org/x/net/html,\x20the\x20go\x20command\x20would\x20try\x20to\x20find\x20the\x20latest\x0aversions\x20of\x20the\x20modules\x20golang.org/x/net/html,\x20golang.org/x/net,\x0agolang.org/x/,\x20and\x20golang.org.\x20Only\x20golang.org/x/net\x20actually\x20exists\x20and\x0aprovides\x20that\x20package,\x20so\x20the\x20go\x20command\x20uses\x20the\x20latest\x20version\x20of\x20that\x0amodule.\x20If\x20more\x20than\x20one\x20module\x20provides\x20the\x20package,\x20the\x20go\x20command\x20will\x20use\x0athe\x20module\x20with\x20the\x20longest\x20path.

\x0a

When\x20the\x20go\x20command\x20requests\x20the\x20latest\x20version\x20of\x20a\x20module,\x20it\x20first\x20sends\x20a\x0arequest\x20for\x20$module/@v/list.\x20If\x20the\x20list\x20is\x20empty\x20or\x20none\x20of\x20the\x20returned\x0aversions\x20can\x20be\x20used,\x20it\x20sends\x20a\x20request\x20for\x20$module/@latest.\x20Once\x20a\x20version\x0ais\x20chosen,\x20the\x20go\x20command\x20sends\x20a\x20$module/@v/$version.info\x20request\x20for\x0ametadata.\x20It\x20may\x20then\x20send\x20$module/@v/$version.mod\x20and\x0a$module/@v/$version.zip\x20requests\x20to\x20load\x20the\x20go.mod\x20file\x20and\x20source\x20code.

\x0a
$\x20curl\x20https://proxy.golang.org/golang.org/x/mod/@v/list\x0av0.1.0\x0av0.2.0\x0a\x0a$\x20curl\x20https://proxy.golang.org/golang.org/x/mod/@v/v0.2.0.info\x0a{"Version":"v0.2.0","Time":"2020-01-02T17:33:45Z"}\x0a
\x0a

After\x20downloading\x20a\x20.mod\x20or\x20.zip\x20file,\x20the\x20go\x20command\x20computes\x20a\x0acryptographic\x20hash\x20and\x20checks\x20that\x20it\x20matches\x20a\x20hash\x20in\x20the\x20main\x20module's\x0ago.sum\x20file.\x20If\x20the\x20hash\x20is\x20not\x20present\x20in\x20go.sum,\x20by\x20default,\x20the\x20go\x0acommand\x20retrieves\x20it\x20from\x20the\x20checksum\x20database.\x20If\x20the\x0acomputed\x20hash\x20does\x20not\x20match,\x20the\x20go\x20command\x20reports\x20a\x20security\x20error\x20and\x20does\x0anot\x20install\x20the\x20file\x20in\x20the\x20module\x20cache.\x20The\x20GOPRIVATE\x20and\x20GONOSUMDB\x0aenvironment\x20variables\x20may\x20be\x20used\x20to\x20disable\x20requests\x0ato\x20the\x20checksum\x20database\x20for\x20specific\x20modules.\x20The\x20GOSUMDB\x20environment\x0avariable\x20may\x20also\x20be\x20set\x20to\x20off\x20to\x20disable\x20requests\x20to\x20the\x20checksum\x20database\x0aentirely.\x20See\x20Authenticating\x20modules\x20for\x20more\x0ainformation.\x20Note\x20that\x20version\x20lists\x20and\x20version\x20metadata\x20returned\x20for\x20.info\x0arequests\x20are\x20not\x20authenticated\x20and\x20may\x20change\x20over\x20time.

\x0aVersion\x20control\x20systems\x0a

The\x20go\x20command\x20may\x20download\x20module\x20source\x20code\x20and\x20metadata\x20directly\x20from\x20a\x0aversion\x20control\x20repository.\x20Downloading\x20a\x20module\x20from\x20a\x0aproxy\x20is\x20usually\x20faster,\x20but\x20connecting\x20directly\x0ato\x20a\x20repository\x20is\x20necessary\x20if\x20a\x20proxy\x20is\x20not\x20available\x20or\x20if\x20a\x20module's\x0arepository\x20is\x20not\x20accessible\x20to\x20a\x20proxy\x20(frequently\x20true\x20for\x20private\x0arepositories).\x20Git,\x20Subversion,\x20Mercurial,\x20Bazaar,\x20and\x20Fossil\x20are\x20supported.\x20A\x0aversion\x20control\x20tool\x20must\x20be\x20installed\x20in\x20a\x20directory\x20in\x20PATH\x20in\x20order\x20for\x20the\x0ago\x20command\x20to\x20use\x20it.

\x0a

To\x20download\x20specific\x20modules\x20from\x20source\x20repositories\x20instead\x20of\x20a\x20proxy,\x20set\x0athe\x20GOPRIVATE\x20or\x20GONOPROXY\x20environment\x20variables.\x20To\x20configure\x20the\x20go\x0acommand\x20to\x20download\x20all\x20modules\x20directly\x20from\x20source\x20repositories,\x20set\x20GOPROXY\x0ato\x20direct.\x20See\x20Environment\x20variables\x20for\x20more\x0ainformation.

\x0aFinding\x20a\x20repository\x20for\x20a\x20module\x20path\x0a

When\x20the\x20go\x20command\x20downloads\x20a\x20module\x20in\x20direct\x20mode,\x20it\x20starts\x20by\x20locating\x0athe\x20repository\x20that\x20contains\x20the\x20module.\x20The\x20go\x20command\x20sends\x20an\x0aHTTP\x20GET\x20request\x20to\x20a\x20URL\x20derived\x20from\x20the\x20module\x20path\x20with\x20a\x0a?go-get=1\x20query\x20string.\x20For\x20example,\x20for\x20the\x20module\x20golang.org/x/mod,\x0athe\x20go\x20command\x20may\x20send\x20the\x20following\x20requests:

\x0a
https://golang.org/x/mod?go-get=1\x20(preferred)\x0ahttp://golang.org/x/mod?go-get=1\x20\x20(fallback,\x20only\x20with\x20GOINSECURE)\x0a
\x0a

The\x20go\x20command\x20will\x20follow\x20redirects\x20but\x20otherwise\x20ignores\x20response\x20status\x0acodes,\x20so\x20the\x20server\x20may\x20respond\x20with\x20a\x20404\x20or\x20any\x20other\x20error\x20status.\x20The\x0aGOINSECURE\x20environment\x20variable\x20may\x20be\x20set\x20to\x20allow\x20fallback\x20and\x20redirects\x20to\x0aunencrypted\x20HTTP\x20for\x20specific\x20modules.

\x0a

The\x20server\x20must\x20respond\x20with\x20an\x20HTML\x20document\x20containing\x20a\x20<meta>\x20tag\x20in\x20the\x0adocument's\x20<head>.\x20The\x20<meta>\x20tag\x20should\x20appear\x20early\x20in\x20the\x20document\x20to\x0aavoid\x20confusing\x20the\x20go\x20command's\x20restricted\x20parser.\x20In\x20particular,\x20it\x20should\x0aappear\x20before\x20any\x20raw\x20JavaScript\x20or\x20CSS.\x20The\x20<meta>\x20tag\x20must\x20have\x20the\x20form:

\x0a
<meta\x20name="go-import"\x20content="root-path\x20vcs\x20repo-url">\x0a
\x0a

root-path\x20is\x20the\x20repository\x20root\x20path,\x20the\x20portion\x20of\x20the\x20module\x20path\x20that\x0acorresponds\x20to\x20the\x20repository's\x20root\x20directory.\x20It\x20must\x20be\x20a\x20prefix\x20or\x20an\x20exact\x0amatch\x20of\x20the\x20requested\x20module\x20path.\x20If\x20it's\x20not\x20an\x20exact\x20match,\x20another\x20request\x0ais\x20made\x20for\x20the\x20prefix\x20to\x20verify\x20the\x20<meta>\x20tags\x20match.

\x0a

vcs\x20is\x20the\x20version\x20control\x20system.\x20It\x20must\x20be\x20one\x20of\x20bzr,\x20fossil,\x20git,\x0ahg,\x20svn,\x20mod.\x20The\x20mod\x20scheme\x20instructs\x20the\x20go\x20command\x20to\x20download\x20the\x0amodule\x20from\x20the\x20given\x20URL\x20using\x20the\x20GOPROXY\x0aprotocol.\x20This\x20allows\x20developers\x20to\x20distribute\x20modules\x0awithout\x20exposing\x20source\x20repositories.

\x0a

repo-url\x20is\x20the\x20repository's\x20URL.\x20If\x20the\x20URL\x20does\x20not\x20include\x20a\x20scheme,\x20the\x0ago\x20command\x20will\x20try\x20each\x20protocol\x20supported\x20by\x20the\x20version\x20control\x20system.\x0aFor\x20example,\x20with\x20Git,\x20the\x20go\x20command\x20will\x20try\x20https://\x20then\x20git+ssh://.\x0aInsecure\x20protocols\x20may\x20only\x20be\x20used\x20if\x20the\x20module\x20path\x20is\x20matched\x20by\x20the\x0aGOINSECURE\x20environment\x20variable.

\x0a

As\x20an\x20example,\x20consider\x20golang.org/x/mod\x20again.\x20The\x20go\x20command\x20sends\x0aa\x20request\x20to\x20https://golang.org/x/mod?go-get=1.\x20The\x20server\x20responds\x0awith\x20an\x20HTML\x20document\x20containing\x20the\x20tag:

\x0a
<meta\x20name="go-import"\x20content="golang.org/x/mod\x20git\x20https://go.googlesource.com/mod">\x0a
\x0a

From\x20this\x20response,\x20the\x20go\x20command\x20will\x20use\x20the\x20Git\x20repository\x20at\x0athe\x20remote\x20URL\x20https://go.googlesource.com/mod.

\x0a

GitHub\x20and\x20other\x20popular\x20hosting\x20services\x20respond\x20to\x20?go-get=1\x20queries\x20for\x0aall\x20repositories,\x20so\x20usually\x20no\x20server\x20configuration\x20is\x20necessary\x20for\x20modules\x0ahosted\x20at\x20those\x20sites.

\x0a

After\x20the\x20repository\x20URL\x20is\x20found,\x20the\x20go\x20command\x20will\x20clone\x20the\x20repository\x0ainto\x20the\x20module\x20cache.\x20In\x20general,\x20the\x20go\x20command\x20tries\x20to\x20avoid\x20fetching\x0aunneeded\x20data\x20from\x20a\x20repository.\x20However,\x20the\x20actual\x20commands\x20used\x20vary\x20by\x0aversion\x20control\x20system\x20and\x20may\x20change\x20over\x20time.\x20For\x20Git,\x20the\x20go\x20command\x20can\x0alist\x20most\x20available\x20versions\x20without\x20downloading\x20commits.\x20It\x20will\x20usually\x20fetch\x0acommits\x20without\x20downloading\x20ancestor\x20commits,\x20but\x20doing\x20so\x20is\x20sometimes\x0anecessary.

\x0aMapping\x20versions\x20to\x20commits\x0a

The\x20go\x20command\x20may\x20check\x20out\x20a\x20module\x20within\x20a\x20repository\x20at\x20a\x20specific\x0acanonical\x20version\x20like\x20v1.2.3,\x20v2.4.0-beta,\x20or\x0av3.0.0+incompatible.\x20Each\x20module\x20version\x20should\x20have\x20a\x20semantic\x20version\x0atag\x20within\x20the\x20repository\x20that\x20indicates\x20which\x20revision\x20should\x20be\x20checked\x0aout\x20for\x20a\x20given\x20version.

\x0a

If\x20a\x20module\x20is\x20defined\x20in\x20the\x20repository\x20root\x20directory\x20or\x20in\x20a\x20major\x20version\x0asubdirectory\x20of\x20the\x20root\x20directory,\x20then\x20each\x20version\x20tag\x20name\x20is\x20equal\x20to\x20the\x0acorresponding\x20version.\x20For\x20example,\x20the\x20module\x20golang.org/x/text\x20is\x20defined\x20in\x0athe\x20root\x20directory\x20of\x20its\x20repository,\x20so\x20the\x20version\x20v0.3.2\x20has\x20the\x20tag\x0av0.3.2\x20in\x20that\x20repository.\x20This\x20is\x20true\x20for\x20most\x20modules.

\x0a

If\x20a\x20module\x20is\x20defined\x20in\x20a\x20subdirectory\x20within\x20the\x20repository,\x20that\x20is,\x20the\x0amodule\x20subdirectory\x20portion\x20of\x20the\x20module\x20path\x20is\x0anot\x20empty,\x20then\x20each\x20tag\x20name\x20must\x20be\x20prefixed\x20with\x20the\x20module\x20subdirectory,\x0afollowed\x20by\x20a\x20slash.\x20For\x20example,\x20the\x20module\x20golang.org/x/tools/gopls\x20is\x0adefined\x20in\x20the\x20gopls\x20subdirectory\x20of\x20the\x20repository\x20with\x20root\x20path\x0agolang.org/x/tools.\x20The\x20version\x20v0.4.0\x20of\x20that\x20module\x20must\x20have\x20the\x20tag\x0anamed\x20gopls/v0.4.0\x20in\x20that\x20repository.

\x0a

The\x20major\x20version\x20number\x20of\x20a\x20semantic\x20version\x20tag\x20must\x20be\x20consistent\x20with\x20the\x0amodule\x20path's\x20major\x20version\x20suffix\x20(if\x20any).\x20For\x20example,\x20the\x20tag\x20v1.0.0\x20could\x0abelong\x20to\x20the\x20module\x20example.com/mod\x20but\x20not\x20example.com/mod/v2,\x20which\x20would\x0ahave\x20tags\x20like\x20v2.0.0.

\x0a

A\x20tag\x20with\x20major\x20version\x20v2\x20or\x20higher\x20may\x20belong\x20to\x20a\x20module\x20without\x20a\x20major\x0aversion\x20suffix\x20if\x20no\x20go.mod\x20file\x20is\x20present,\x20and\x20the\x20module\x20is\x20in\x20the\x0arepository\x20root\x20directory.\x20This\x20kind\x20of\x20version\x20is\x20denoted\x20with\x20the\x20suffix\x0a+incompatible.\x20The\x20version\x20tag\x20itself\x20must\x20not\x20have\x20the\x20suffix.\x20See\x0aCompatibility\x20with\x20non-module\x20repositories.

\x0a

Once\x20a\x20tag\x20is\x20created,\x20it\x20should\x20not\x20be\x20deleted\x20or\x20changed\x20to\x20a\x20different\x0arevision.\x20Versions\x20are\x20authenticated\x20to\x20ensure\x20safe,\x0arepeatable\x20builds.\x20If\x20a\x20tag\x20is\x20modified,\x20clients\x20may\x20see\x20a\x20security\x20error\x20when\x0adownloading\x20it.\x20Even\x20after\x20a\x20tag\x20is\x20deleted,\x20its\x20content\x20may\x20remain\x0aavailable\x20on\x20module\x20proxies.

\x0aMapping\x20pseudo-versions\x20to\x20commits\x0a

The\x20go\x20command\x20may\x20check\x20out\x20a\x20module\x20within\x20a\x20repository\x20at\x20a\x20specific\x0arevision,\x20encoded\x20as\x20a\x20pseudo-version\x20like\x0av1.3.2-0.20191109021931-daa7c04131f5.

\x0a

The\x20last\x2012\x20characters\x20of\x20the\x20pseudo-version\x20(daa7c04131f5\x20in\x20the\x20example\x0aabove)\x20indicate\x20a\x20revision\x20in\x20the\x20repository\x20to\x20check\x20out.\x20The\x20meaning\x20of\x20this\x0adepends\x20on\x20the\x20version\x20control\x20system.\x20For\x20Git\x20and\x20Mercurial,\x20this\x20is\x20a\x20prefix\x0aof\x20a\x20commit\x20hash.\x20For\x20Subversion,\x20this\x20is\x20a\x20zero-padded\x20revision\x20number.

\x0a

Before\x20checking\x20out\x20a\x20commit,\x20the\x20go\x20command\x20verifies\x20that\x20the\x20timestamp\x0a(20191109021931\x20above)\x20matches\x20the\x20commit\x20date.\x20It\x20also\x20verifies\x20that\x20the\x20base\x0aversion\x20(v1.3.1,\x20the\x20version\x20before\x20v1.3.2\x20in\x20the\x20example\x20above)\x20corresponds\x0ato\x20a\x20semantic\x20version\x20tag\x20that\x20is\x20an\x20ancestor\x20of\x20the\x20commit.\x20These\x20checks\x20ensure\x0athat\x20module\x20authors\x20have\x20full\x20control\x20over\x20how\x20pseudo-versions\x20compare\x20with\x0aother\x20released\x20versions.

\x0a

See\x20Pseudo-versions\x20for\x20more\x20information.

\x0aMapping\x20branches\x20and\x20commits\x20to\x20versions\x0a

A\x20module\x20may\x20be\x20checked\x20out\x20at\x20a\x20specific\x20branch,\x20tag,\x20or\x20revision\x20using\x20a\x0aversion\x20query.

\x0a
go\x20get\x20example.com/mod@master\x0a
\x0a

The\x20go\x20command\x20converts\x20these\x20names\x20into\x20canonical\x0aversions\x20that\x20can\x20be\x20used\x20with\x20minimal\x20version\x0aselection\x20(MVS).\x20MVS\x20depends\x20on\x20the\x20ability\x20to\x0aorder\x20versions\x20unambiguously.\x20Branch\x20names\x20and\x20revisions\x20can't\x20be\x20compared\x0areliably\x20over\x20time,\x20since\x20they\x20depend\x20on\x20repository\x20structure\x20which\x20may\x20change.

\x0a

If\x20a\x20revision\x20is\x20tagged\x20with\x20one\x20or\x20more\x20semantic\x20version\x20tags\x20like\x20v1.2.3,\x0athe\x20tag\x20for\x20the\x20highest\x20valid\x20version\x20will\x20be\x20used.\x20The\x20go\x20command\x20only\x0aconsiders\x20semantic\x20version\x20tags\x20that\x20could\x20belong\x20to\x20the\x20target\x20module;\x20for\x0aexample,\x20the\x20tag\x20v1.5.2\x20would\x20not\x20be\x20considered\x20for\x20example.com/mod/v2\x20since\x0athe\x20major\x20version\x20doesn't\x20match\x20the\x20module\x20path's\x20suffix.

\x0a

If\x20a\x20revision\x20is\x20not\x20tagged\x20with\x20a\x20valid\x20semantic\x20version\x20tag,\x20the\x20go\x20command\x0awill\x20generate\x20a\x20pseudo-version.\x20If\x20the\x20revision\x20has\x0aancestors\x20with\x20valid\x20semantic\x20version\x20tags,\x20the\x20highest\x20ancestor\x20version\x20will\x20be\x0aused\x20as\x20the\x20pseudo-version\x20base.\x20See\x20Pseudo-versions.

\x0aModule\x20directories\x20within\x20a\x20repository\x0a

Once\x20a\x20module's\x20repository\x20has\x20been\x20checked\x20out\x20at\x20a\x20specific\x20revision,\x20the\x20go\x0acommand\x20must\x20locate\x20the\x20directory\x20that\x20contains\x20the\x20module's\x20go.mod\x20file\x0a(the\x20module's\x20root\x20directory).

\x0a

Recall\x20that\x20a\x20module\x20path\x20consists\x20of\x20three\x20parts:\x20a\x0arepository\x20root\x20path\x20(corresponding\x20to\x20the\x20repository\x20root\x20directory),\x0aa\x20module\x20subdirectory,\x20and\x20a\x20major\x20version\x20suffix\x20(only\x20for\x20modules\x20released\x20at\x0av2\x20or\x20higher).

\x0a

For\x20most\x20modules,\x20the\x20module\x20path\x20is\x20equal\x20to\x20the\x20repository\x20root\x20path,\x20so\x0athe\x20module's\x20root\x20directory\x20is\x20the\x20repository's\x20root\x20directory.

\x0a

Modules\x20are\x20sometimes\x20defined\x20in\x20repository\x20subdirectories.\x20This\x20is\x20typically\x0adone\x20for\x20large\x20repositories\x20with\x20multiple\x20components\x20that\x20need\x20to\x20be\x20released\x0aand\x20versioned\x20indepently.\x20Such\x20a\x20module\x20is\x20expected\x20to\x20be\x20found\x20in\x20a\x0asubdirectory\x20that\x20matches\x20the\x20part\x20of\x20the\x20module's\x20path\x20after\x20the\x20repository\x0aroot\x20path.\x20\x20For\x20example,\x20suppose\x20the\x20module\x20example.com/monorepo/foo/bar\x20is\x20in\x0athe\x20repository\x20with\x20root\x20path\x20example.com/monorepo.\x20Its\x20go.mod\x20file\x20must\x20be\x0ain\x20the\x20foo/bar\x20subdirectory.

\x0a

If\x20a\x20module\x20is\x20released\x20at\x20major\x20version\x20v2\x20or\x20higher,\x20its\x20path\x20must\x20have\x20a\x0amajor\x20version\x20suffix.\x20A\x20module\x20with\x20a\x20major\x20version\x0asuffix\x20may\x20be\x20defined\x20in\x20one\x20of\x20two\x20subdirectories:\x20one\x20with\x20the\x20suffix,\x0aand\x20one\x20without.\x20For\x20example,\x20suppose\x20a\x20new\x20version\x20of\x20the\x20module\x20above\x20is\x0areleased\x20with\x20the\x20path\x20example.com/monorepo/foo/bar/v2.\x20Its\x20go.mod\x20file\x0amay\x20be\x20in\x20either\x20foo/bar\x20or\x20foo/bar/v2.

\x0a

Subdirectories\x20with\x20a\x20major\x20version\x20suffix\x20are\x20major\x20version\x0asubdirectories.\x20They\x20may\x20be\x20used\x20to\x20develop\x20multiple\x20major\x20versions\x20of\x20a\x0amodule\x20on\x20a\x20single\x20branch.\x20This\x20may\x20be\x20unnecessary\x20when\x20development\x20of\x20multiple\x0amajor\x20versions\x20proceeds\x20on\x20separate\x20branches.\x20However,\x20major\x20version\x0asubdirectories\x20have\x20an\x20important\x20property:\x20in\x20GOPATH\x20mode,\x20package\x20import\x0apaths\x20exactly\x20match\x20directories\x20under\x20GOPATH/src.\x20The\x20go\x20command\x20provides\x0aminimal\x20module\x20compatibility\x20in\x20GOPATH\x20mode\x20(see\x20Compatibility\x20with\x0anon-module\x20repositories),\x20so\x20major\x20version\x0asubdirectories\x20aren't\x20always\x20necessary\x20for\x20compatibility\x20with\x20projects\x20built\x20in\x0aGOPATH\x20mode.\x20Older\x20tools\x20that\x20don't\x20support\x20minimal\x20module\x20compatibility\x0amay\x20have\x20problems\x20though.

\x0a

Once\x20the\x20go\x20command\x20has\x20found\x20the\x20module\x20root\x20directory,\x20it\x20creates\x20a\x20.zip\x0afile\x20of\x20the\x20contents\x20of\x20the\x20directory,\x20then\x20extracts\x20the\x20.zip\x20file\x20into\x20the\x0amodule\x20cache.\x20See\x20File\x20path\x20and\x20size\x20constraints)\x0afor\x20details\x20on\x20what\x20files\x20may\x20be\x20included\x20in\x20the\x20.zip\x20file.\x20The\x20contents\x20of\x0athe\x20.zip\x20file\x20are\x20authenticated\x20before\x20extraction\x20into\x20the\x0amodule\x20cache\x20the\x20same\x20way\x20they\x20would\x20be\x20if\x20the\x20.zip\x20file\x20were\x20downloaded\x20from\x0aa\x20proxy.

\x0aModule\x20zip\x20files\x0a

Module\x20versions\x20are\x20distributed\x20as\x20.zip\x20files.\x20There\x20is\x20rarely\x20any\x20need\x20to\x0ainteract\x20directly\x20with\x20these\x20files,\x20since\x20the\x20go\x20command\x20creates,\x20downloads,\x0aand\x20extracts\x20them\x20automatically\x20from\x20module\x20proxies\x20and\x0aversion\x20control\x20repositories.\x20However,\x20it's\x20still\x20useful\x20to\x20know\x20about\x20these\x0afiles\x20to\x20understand\x20cross-platform\x20compatibility\x20constraints\x20or\x20when\x0aimplementing\x20a\x20module\x20proxy.

\x0a

The\x20go\x20mod\x20download\x20command\x20downloads\x20zip\x20files\x0afor\x20one\x20or\x20more\x20modules,\x20then\x20extracts\x20those\x20files\x20into\x20the\x20module\x0acache.\x20Depending\x20on\x20GOPROXY\x20and\x20other\x20environment\x0avariables,\x20the\x20go\x20command\x20may\x20either\x20download\x0azip\x20files\x20from\x20a\x20proxy\x20or\x20clone\x20source\x20control\x20repositories\x20and\x20create\x0azip\x20files\x20from\x20them.\x20The\x20-json\x20flag\x20may\x20be\x20used\x20to\x20find\x20the\x20location\x20of\x0adownload\x20zip\x20files\x20and\x20their\x20extracted\x20contents\x20in\x20the\x20module\x20cache.

\x0a

The\x20golang.org/x/mod/zip\x0apackage\x20may\x20be\x20used\x20to\x20create,\x20extract,\x20or\x20check\x20contents\x20of\x20zip\x20files\x0aprogrammatically.

\x0aFile\x20path\x20and\x20size\x20constraints\x0a

There\x20are\x20a\x20number\x20of\x20restrictions\x20on\x20the\x20content\x20of\x20module\x20zip\x20files.\x20These\x0aconstraints\x20ensure\x20that\x20zip\x20files\x20can\x20be\x20extracted\x20safely\x20and\x20consistently\x20on\x0aa\x20wide\x20range\x20of\x20platforms.

\x0a
    \x0a
  • A\x20module\x20zip\x20file\x20may\x20be\x20at\x20most\x20500\x20MiB\x20in\x20size.\x20The\x20total\x20uncompressed\x20size\x0aof\x20its\x20files\x20is\x20also\x20limited\x20to\x20500\x20MiB.\x20go.mod\x20files\x20are\x20limited\x20to\x2016\x20MiB.\x0aLICENSE\x20files\x20are\x20also\x20limited\x20to\x2016\x20MiB.\x20These\x20limits\x20exist\x20to\x20mitigate\x0adenial\x20of\x20service\x20attacks\x20on\x20users,\x20proxies,\x20and\x20other\x20parts\x20of\x20the\x20module\x0aecosystem.\x20Repositories\x20that\x20contain\x20more\x20than\x20500\x20MiB\x20of\x20files\x20in\x20a\x20module\x0adirectory\x20tree\x20should\x20tag\x20module\x20versions\x20at\x20commits\x20that\x20only\x20include\x20files\x0aneeded\x20to\x20build\x20the\x20module's\x20packages;\x20videos,\x20models,\x20and\x20other\x20large\x20assets\x0aare\x20usually\x20not\x20needed\x20for\x20builds.
  • \x0a
  • Each\x20file\x20within\x20a\x20module\x20zip\x20file\x20must\x20begin\x20with\x20the\x20prefix\x0a$module@$version/\x20where\x20$module\x20is\x20the\x20module\x20path\x20and\x20$version\x20is\x20the\x0aversion,\x20for\x20example,\x20golang.org/x/mod@v0.3.0/.\x20The\x20module\x20path\x20must\x20be\x0avalid,\x20the\x20version\x20must\x20be\x20valid\x20and\x20canonical,\x20and\x20the\x20version\x20must\x20match\x20the\x0amodule\x20path's\x20major\x20version\x20suffix.\x20See\x20Module\x20paths\x20and\x0aversions\x20for\x20specific\x20definitions\x20and\x20restrictions.
  • \x0a
  • File\x20modes,\x20timestamps,\x20and\x20other\x20metadata\x20are\x20ignored.
  • \x0a
  • Empty\x20directories\x20(entries\x20with\x20paths\x20ending\x20with\x20a\x20slash)\x20may\x20be\x20included\x0ain\x20module\x20zip\x20files\x20but\x20are\x20not\x20extracted.\x20The\x20go\x20command\x20does\x20not\x20include\x0aempty\x20directories\x20in\x20zip\x20files\x20it\x20creates.
  • \x0a
  • Symbolic\x20links\x20and\x20other\x20irregular\x20files\x20are\x20ignored\x20when\x20creating\x20zip\x20files,\x0asince\x20they\x20aren't\x20portable\x20across\x20operating\x20systems\x20and\x20file\x20systems,\x20and\x0athere's\x20no\x20portable\x20way\x20to\x20represent\x20them\x20in\x20the\x20zip\x20file\x20format.
  • \x0a
  • No\x20two\x20files\x20within\x20a\x20zip\x20file\x20may\x20have\x20paths\x20equal\x20under\x20Unicode\x20case-folding\x0a(see\x20strings.EqualFold).\x0aThis\x20ensures\x20that\x20zip\x20files\x20can\x20be\x20extracted\x20on\x20case-insensitive\x20file\x20systems\x0awithout\x20collisions.
  • \x0a
  • A\x20go.mod\x20file\x20may\x20or\x20may\x20not\x20appear\x20in\x20the\x20top-level\x20directory\x0a($module@$version/go.mod).\x20If\x20present,\x20it\x20must\x20have\x20the\x20name\x20go.mod\x20(all\x0alowercase).\x20Files\x20named\x20go.mod\x20are\x20not\x20allowed\x20in\x20any\x20other\x20directory.
  • \x0a
  • File\x20and\x20directory\x20names\x20within\x20a\x20module\x20may\x20consist\x20of\x20Unicode\x20letters,\x20ASCII\x0adigits,\x20the\x20ASCII\x20space\x20character\x20(U+0020),\x20and\x20the\x20ASCII\x20punctuation\x0acharacters\x20!#$%&()+,-.=@[]^_{}~.\x20Note\x20that\x20package\x20paths\x20may\x20not\x20contain\x20all\x0athese\x20all\x20these\x20characters.\x20See\x0amodule.CheckFilePath\x0aand\x0amodule.CheckImportPath\x0afor\x20the\x20differences.
  • \x0a
  • A\x20file\x20or\x20directory\x20name\x20up\x20to\x20the\x20first\x20dot\x20must\x20not\x20be\x20a\x20reserved\x20file\x20name\x0aon\x20Windows,\x20regardless\x20of\x20case\x20(CON,\x20com1,\x20NuL,\x20and\x20so\x20on).
  • \x0a
\x0aPrivate\x20modules\x0a

Go\x20modules\x20are\x20frequently\x20developed\x20and\x20distributed\x20on\x20version\x20control\x20servers\x0aand\x20module\x20proxies\x20that\x20aren't\x20available\x20on\x20the\x20public\x20internet.\x20The\x20go\x0acommand\x20can\x20download\x20and\x20build\x20modules\x20from\x20private\x20sources,\x20though\x20it\x20usually\x0arequires\x20some\x20configuration.

\x0a

The\x20environment\x20variables\x20below\x20may\x20be\x20used\x20to\x20configure\x20access\x20to\x20private\x0amodules.\x20See\x20Environment\x20variables\x20for\x20details.\x20See\x0aalso\x20Privacy\x20for\x20information\x20on\x20controlling\x0ainformation\x20sent\x20to\x20public\x20servers.

\x0a
    \x0a
  • GOPROXY\x20\xe2\x80\x94\x20list\x20of\x20module\x20proxy\x20URLs.\x20The\x20go\x20command\x20will\x20attempt\x20to\x0adownload\x20modules\x20from\x20each\x20server\x20in\x20sequence.\x20The\x20keyword\x20direct\x20instructs\x0athe\x20go\x20command\x20to\x20download\x20modules\x20from\x20version\x20control\x20repositories\x0awhere\x20they're\x20developed\x20instead\x20of\x20using\x20a\x20proxy.
  • \x0a
  • GOPRIVATE\x20\xe2\x80\x94\x20list\x20of\x20glob\x20patterns\x20of\x20module\x20path\x20prefixes\x20that\x20should\x20be\x0aconsidered\x20private.\x20Acts\x20as\x20a\x20default\x20value\x20for\x20GONOPROXY\x20and\x20GONOSUMDB.
  • \x0a
  • GONOPROXY\x20\xe2\x80\x94\x20list\x20of\x20glob\x20patterns\x20of\x20module\x20path\x20prefixes\x20that\x20should\x20not\x20be\x0adownloaded\x20from\x20a\x20proxy.\x20The\x20go\x20command\x20will\x20download\x20matching\x20modules\x20from\x0aversion\x20control\x20repositories\x20where\x20they're\x20developed,\x20regardless\x20of\x20GOPROXY.
  • \x0a
  • GONOSUMDB\x20\xe2\x80\x94\x20list\x20of\x20glob\x20patterns\x20of\x20module\x20path\x20prefixes\x20that\x20should\x20not\x20be\x0achecked\x20using\x20the\x20public\x20checksum\x20database,\x0asum.golang.org.
  • \x0a
  • GOINSECURE\x20\xe2\x80\x94\x20list\x20of\x20glob\x20patterns\x20of\x20module\x20path\x20prefixes\x20that\x20may\x20be\x0aretrieved\x20over\x20HTTP\x20and\x20other\x20insecure\x20protocols.
  • \x0a
\x0a

These\x20variables\x20may\x20be\x20set\x20in\x20the\x20development\x20environment\x20(for\x20example,\x20in\x20a\x0a.profile\x20file),\x20or\x20they\x20may\x20be\x20set\x20permanently\x20with\x20go\x20env\x20-w.

\x0a

The\x20rest\x20of\x20this\x20section\x20describes\x20common\x20patterns\x20for\x20providing\x20access\x20to\x0aprivate\x20module\x20proxies\x20and\x20version\x20control\x20repositories.

\x0aPrivate\x20proxy\x20serving\x20all\x20modules\x0a

A\x20central\x20private\x20proxy\x20server\x20that\x20serves\x20all\x20modules\x20(public\x20and\x20private)\x0aprovides\x20the\x20most\x20control\x20for\x20administrators\x20and\x20requires\x20the\x20least\x0aconfiguration\x20for\x20individual\x20developers.

\x0a

To\x20configure\x20the\x20go\x20command\x20to\x20use\x20such\x20a\x20server,\x20set\x20the\x20following\x0aenvironment\x20variables,\x20replacing\x20https://proxy.corp.example.com\x20with\x20your\x0aproxy\x20URL\x20and\x20corp.example.com\x20with\x20your\x20module\x20prefix:

\x0a
GOPROXY=https://proxy.corp.example.com\x0aGONOSUMDB=corp.example.com\x0a
\x0a

The\x20GOPROXY\x20setting\x20instructs\x20the\x20go\x20command\x20to\x20only\x20download\x20modules\x20from\x0ahttps://proxy.corp.example.com;\x20the\x20go\x20command\x20will\x20not\x20connect\x20to\x20other\x0aproxies\x20or\x20version\x20control\x20repositories.

\x0a

The\x20GONOSUMDB\x20setting\x20instructs\x20the\x20go\x20command\x20not\x20to\x20use\x20the\x20public\x0achecksum\x20database\x20to\x20authenticate\x20modules\x20with\x20paths\x20starting\x20with\x0acorp.example.com.

\x0a

A\x20proxy\x20running\x20in\x20this\x20configuration\x20will\x20likely\x20need\x20read\x20access\x20to\x0aprivate\x20version\x20control\x20servers.\x20It\x20will\x20also\x20need\x20access\x20to\x20the\x20public\x20internet\x0ato\x20download\x20new\x20versions\x20of\x20public\x20modules.

\x0a

There\x20are\x20several\x20existing\x20implementations\x20of\x20GOPROXY\x20servers\x20that\x20may\x20be\x20used\x0athis\x20way.\x20A\x20minimal\x20implementation\x20would\x20serve\x20files\x20from\x20a\x20module\x0acache\x20directory\x20and\x20would\x20use\x20go\x20mod\x20download\x20(with\x20suitable\x20configuration)\x20to\x20retrieve\x20missing\x0amodules.

\x0aPrivate\x20proxy\x20serving\x20private\x20modules\x0a

A\x20private\x20proxy\x20server\x20may\x20serve\x20private\x20modules\x20without\x20also\x20serving\x20publicly\x0aavailable\x20modules.\x20The\x20go\x20command\x20can\x20be\x20configured\x20to\x20fall\x20back\x20to\x0apublic\x20sources\x20for\x20modules\x20that\x20aren't\x20available\x20on\x20the\x20private\x20server.

\x0a

To\x20configure\x20the\x20go\x20command\x20to\x20work\x20this\x20way,\x20set\x20the\x20following\x20environment\x0avariables,\x20replacing\x20https://proxy.corp.example.com\x20with\x20the\x20proxy\x20URL\x20and\x0acorp.example.com\x20with\x20the\x20module\x20prefix:

\x0a
GOPROXY=https://proxy.corp.example.com,https://proxy.golang.org,direct\x0aGONOSUMDB=corp.example.com\x0a
\x0a

The\x20GOPROXY\x20setting\x20instructs\x20the\x20go\x20command\x20to\x20try\x20to\x20download\x20modules\x20from\x0ahttps://proxy.corp.example.com\x20first.\x20If\x20that\x20server\x20responds\x20with\x20404\x20(Not\x0aFound)\x20or\x20410\x20(Gone),\x20the\x20go\x20command\x20will\x20fall\x20back\x20to\x0ahttps://proxy.golang.org,\x20then\x20to\x20direct\x20connections\x20to\x20repositories.

\x0a

The\x20GONOSUMDB\x20setting\x20instructs\x20the\x20go\x20command\x20not\x20to\x20use\x20the\x20public\x20checksum\x0adatabase\x20to\x20authenticate\x20modules\x20whose\x20paths\x20start\x20with\x20corp.example.com.

\x0a

Note\x20that\x20a\x20proxy\x20used\x20in\x20this\x20configuration\x20may\x20still\x20control\x20access\x20to\x20public\x0amodules,\x20even\x20though\x20it\x20doesn't\x20serve\x20them.\x20If\x20the\x20proxy\x20responds\x20to\x20a\x20request\x0awith\x20an\x20error\x20status\x20other\x20than\x20404\x20or\x20410,\x20the\x20go\x20command\x20will\x20not\x20fall\x20back\x0ato\x20later\x20entries\x20in\x20the\x20GOPROXY\x20list.\x20For\x20example,\x20the\x20proxy\x20could\x20respond\x0awith\x20403\x20(Forbidden)\x20for\x20a\x20module\x20with\x20an\x20unsuitable\x20license\x20or\x20with\x20known\x0asecurity\x20vulnerabilities.

\x0aDirect\x20access\x20to\x20private\x20modules\x0a

The\x20go\x20command\x20may\x20be\x20configured\x20to\x20bypass\x20public\x20proxies\x20and\x20download\x20private\x0amodules\x20directly\x20from\x20version\x20control\x20servers.\x20This\x20is\x20useful\x20when\x20running\x20a\x0aprivate\x20proxy\x20server\x20is\x20not\x20feasible.

\x0a

To\x20configure\x20the\x20go\x20command\x20to\x20work\x20this\x20way,\x20set\x20GOPRIVATE,\x20replacing\x0acorp.example.com\x20the\x20private\x20module\x20prefix:

\x0a
GOPRIVATE=corp.example.com\x0a
\x0a

The\x20GOPROXY\x20variable\x20does\x20not\x20need\x20to\x20be\x20changed\x20in\x20this\x20situation.\x20It\x0adefaults\x20to\x20https://proxy.golang.org,direct,\x20which\x20instructs\x20the\x20go\x20command\x0ato\x20attempt\x20to\x20download\x20modules\x20from\x20https://proxy.golang.org\x20first,\x20then\x20fall\x0aback\x20to\x20a\x20direct\x20connection\x20if\x20that\x20proxy\x20responds\x20with\x20404\x20(Not\x20Found)\x20or\x20410\x0a(Gone).

\x0a

The\x20GOPRIVATE\x20setting\x20instructs\x20the\x20go\x20command\x20not\x20to\x20connect\x20to\x20a\x20proxy\x20or\x0ato\x20the\x20checksum\x20database\x20for\x20modules\x20starting\x20with\x20corp.example.com.

\x0a

An\x20internal\x20HTTP\x20server\x20may\x20still\x20be\x20needed\x20to\x20resolve\x20module\x20paths\x20to\x0arepository\x20URLs.\x20For\x20example,\x20when\x20the\x20go\x20command\x20downloads\x20the\x0amodule\x20corp.example.com/mod,\x20it\x20will\x20send\x20a\x20GET\x20request\x20to\x0ahttps://corp.example.com/mod?go-get=1,\x20and\x20it\x20will\x20look\x20for\x20the\x20repository\x20URL\x0ain\x20the\x20response.\x20To\x20avoid\x20this\x20requirement,\x20ensure\x20that\x20each\x20private\x20module\x20path\x0ahas\x20a\x20VCS\x20suffix\x20(like\x20.git)\x20marking\x20the\x20repository\x20root\x20prefix.\x20For\x20example,\x0awhen\x20the\x20go\x20command\x20downloads\x20the\x20module\x20corp.example.com/repo.git/mod,\x20it\x0awill\x20clone\x20the\x20Git\x20repository\x20at\x20https://corp.example.com/repo.git\x20or\x0assh://corp.example.com/repo.git\x20without\x20needing\x20to\x20make\x20additional\x20requests.

\x0a

Developers\x20will\x20need\x20read\x20access\x20to\x20repositories\x20containing\x20private\x20modules.\x0aThis\x20may\x20be\x20configured\x20in\x20global\x20VCS\x20configuration\x20files\x20like\x20.gitconfig.\x0aIt's\x20best\x20if\x20VCS\x20tools\x20are\x20configured\x20not\x20to\x20need\x20interactive\x20authentication\x0aprompts.\x20By\x20default,\x20when\x20invoking\x20Git,\x20the\x20go\x20command\x20disables\x20interactive\x0aprompts\x20by\x20setting\x20GIT_TERMINAL_PROMPT=0,\x20but\x20it\x20respects\x20explicit\x20settings.

\x0aPassing\x20credentials\x20to\x20private\x20proxies\x0a

The\x20go\x20command\x20supports\x20HTTP\x20basic\x0aauthentication\x20when\x0acommunicating\x20with\x20proxy\x20servers.

\x0a

Credentials\x20may\x20be\x20specified\x20in\x20a\x20.netrc\x0afile.\x0aFor\x20example,\x20a\x20.netrc\x20file\x20containing\x20the\x20lines\x20below\x20would\x20configure\x20the\x20go\x0acommand\x20to\x20connect\x20to\x20the\x20machine\x20proxy.corp.example.com\x20with\x20the\x20given\x0ausername\x20and\x20password.

\x0a
machine\x20proxy.corp.example.com\x0alogin\x20jrgopher\x0apassword\x20hunter2\x0a
\x0a

The\x20location\x20of\x20the\x20file\x20may\x20be\x20set\x20with\x20the\x20NETRC\x20environment\x20variable.\x20If\x0aNETRC\x20is\x20not\x20set,\x20the\x20go\x20command\x20will\x20read\x20$HOME/.netrc\x20on\x20UNIX-like\x0aplatforms\x20or\x20%USERPROFILE%\\_netrc\x20on\x20Windows.

\x0a

Fields\x20in\x20.netrc\x20are\x20separated\x20with\x20spaces,\x20tabs,\x20and\x20newlines.\x20Unfortunately,\x0athese\x20characters\x20cannot\x20be\x20used\x20in\x20usernames\x20or\x20passwords.\x20Note\x20also\x20that\x20the\x0amachine\x20name\x20cannot\x20be\x20a\x20full\x20URL,\x20so\x20it's\x20not\x20possible\x20to\x20specify\x20different\x0ausernames\x20and\x20passwords\x20for\x20different\x20paths\x20on\x20the\x20same\x20machine.

\x0a

Alternatively,\x20credentials\x20may\x20be\x20specified\x20directly\x20in\x20GOPROXY\x20URLs.\x20For\x0aexample:

\x0a
GOPROXY=https://jrgopher:hunter2@proxy.corp.example.com\x0a
\x0a

Use\x20caution\x20when\x20taking\x20this\x20approach:\x20environment\x20variables\x20may\x20be\x20appear\x0ain\x20shell\x20history\x20and\x20in\x20logs.

\x0aPrivacy\x0a

The\x20go\x20command\x20may\x20download\x20modules\x20and\x20metadata\x20from\x20module\x20proxy\x0aservers\x20and\x20version\x20control\x20systems.\x20The\x20environment\x20variable\x20GOPROXY\x0acontrols\x20which\x20servers\x20are\x20used.\x20The\x20environment\x20variables\x20GOPRIVATE\x20and\x0aGONOPROXY\x20control\x20which\x20modules\x20are\x20fetched\x20from\x20proxies.

\x0a

The\x20default\x20value\x20of\x20GOPROXY\x20is:

\x0a
https://proxy.golang.org,direct\x0a
\x0a

With\x20this\x20setting,\x20when\x20the\x20go\x20command\x20downloads\x20a\x20module\x20or\x20module\x20metadata,\x0ait\x20will\x20first\x20send\x20a\x20request\x20to\x20proxy.golang.org,\x20a\x20public\x20module\x20proxy\x0aoperated\x20by\x20Google\x20(privacy\x20policy).\x20See\x0aGOPROXY\x20protocol\x20for\x20details\x20on\x20what\x20information\x20is\x20sent\x0ain\x20each\x20request.\x20The\x20go\x20command\x20does\x20not\x20transmit\x20personally\x20identifiable\x0ainformation,\x20but\x20it\x20does\x20transmit\x20the\x20full\x20module\x20path\x20being\x20requested.\x20If\x20the\x0aproxy\x20responds\x20with\x20a\x20404\x20(Not\x20Found)\x20or\x20410\x20(Gone)\x20status,\x20the\x20go\x20command\x0awill\x20attempt\x20to\x20connect\x20directly\x20to\x20the\x20version\x20control\x20system\x20providing\x20the\x0amodule.\x20See\x20Version\x20control\x20systems\x20for\x20details.

\x0a

The\x20GOPRIVATE\x20or\x20GONOPROXY\x20environment\x20variables\x20may\x20be\x20set\x20to\x20lists\x20of\x20glob\x0apatterns\x20matching\x20module\x20prefixes\x20that\x20are\x20private\x20and\x20should\x20not\x20be\x20requested\x0afrom\x20any\x20proxy.\x20For\x20example:

\x0a
GOPRIVATE=*.corp.example.com,*.research.example.com\x0a
\x0a

GOPRIVATE\x20simply\x20acts\x20as\x20a\x20default\x20for\x20GONOPROXY\x20and\x20GONOSUMDB,\x20so\x20it's\x0anot\x20necessary\x20to\x20set\x20GONOPROXY\x20unless\x20GONOSUMDB\x20should\x20have\x20a\x20different\x0avalue.\x20When\x20a\x20module\x20path\x20is\x20matched\x20by\x20GONOPROXY,\x20the\x20go\x20command\x20ignores\x0aGOPROXY\x20for\x20that\x20module\x20and\x20fetches\x20it\x20directly\x20from\x20its\x20version\x20control\x0arepository.\x20This\x20is\x20useful\x20when\x20no\x20proxy\x20serves\x20private\x20modules.\x20See\x20Direct\x0aaccess\x20to\x20private\x20modules.

\x0a

If\x20there\x20is\x20a\x20trusted\x20proxy\x20serving\x20all\x20modules,\x0athen\x20GONOPROXY\x20should\x20not\x20be\x20set.\x20For\x20example,\x20if\x20GOPROXY\x20is\x20set\x20to\x20one\x0asource,\x20the\x20go\x20command\x20will\x20not\x20download\x20modules\x20from\x20other\x20sources.\x0aGONOSUMDB\x20should\x20still\x20be\x20set\x20in\x20this\x20situation.

\x0a
GOPROXY=https://proxy.corp.example.com\x0aGONOSUMDB=*.corp.example.com,*.research.example.com\x0a
\x0a

If\x20there\x20is\x20a\x20trusted\x20proxy\x20serving\x20only\x20private\x0amodules,\x20GONOPROXY\x20should\x20not\x20be\x20set,\x20but\x20care\x0amust\x20be\x20taken\x20to\x20ensure\x20the\x20proxy\x20responds\x20with\x20the\x20correct\x20status\x20codes.\x20For\x0aexample,\x20consider\x20the\x20following\x20configuration:

\x0a
GOPROXY=https://proxy.corp.example.com,https://proxy.golang.org\x0aGONOSUMDB=*.corp.example.com,*.research.example.com\x0a
\x0a

Suppose\x20that\x20due\x20to\x20a\x20typo,\x20a\x20developer\x20attempts\x20to\x20download\x20a\x20module\x20that\x0adoesn't\x20exist.

\x0a
go\x20mod\x20download\x20corp.example.com/secret-product/typo@latest\x0a
\x0a

The\x20go\x20command\x20first\x20requests\x20this\x20module\x20from\x20proxy.corp.example.com.\x20If\x0athat\x20proxy\x20responds\x20with\x20404\x20(Not\x20Found)\x20or\x20410\x20(Gone),\x20the\x20go\x20command\x20will\x0afall\x20back\x20to\x20proxy.golang.org,\x20transmitting\x20the\x20secret-product\x20path\x20in\x20the\x0arequest\x20URL.\x20If\x20the\x20private\x20proxy\x20responds\x20with\x20any\x20other\x20error\x20code,\x20the\x20go\x0acommand\x20prints\x20the\x20error\x20and\x20will\x20not\x20fall\x20back\x20to\x20other\x20sources.

\x0a

In\x20addition\x20to\x20proxies,\x20the\x20go\x20command\x20may\x20connect\x20to\x20the\x20checksum\x20database\x20to\x0averify\x20cryptographic\x20hashes\x20of\x20modules\x20not\x20listed\x20in\x20go.sum.\x20The\x20GOSUMDB\x0aenvironment\x20variable\x20sets\x20the\x20name,\x20URL,\x20and\x20public\x20key\x20of\x20the\x20checksum\x0adatabase.\x20The\x20default\x20value\x20of\x20GOSUMDB\x20is\x20sum.golang.org,\x20the\x20public\x0achecksum\x20database\x20operated\x20by\x20Google\x20(privacy\x0apolicy).\x20See\x20Checksum\x0adatabase\x20for\x20details\x20on\x20what\x20is\x20transmitted\x20with\x20each\x0arequest.\x20As\x20with\x20proxies,\x20the\x20go\x20command\x20does\x20not\x20transmit\x20personally\x0aidentifiable\x20information,\x20but\x20it\x20does\x20transmit\x20the\x20full\x20module\x20path\x20being\x0arequested,\x20and\x20the\x20checksum\x20database\x20cannot\x20compute\x20checksums\x20for\x20non-public\x0amodules.

\x0a

The\x20GONOSUMDB\x20environment\x20variable\x20may\x20be\x20set\x20to\x20patterns\x20indicating\x20which\x0amodules\x20are\x20private\x20and\x20should\x20not\x20be\x20requested\x20from\x20the\x20checksum\x0adatabase.\x20GOPRIVATE\x20acts\x20as\x20a\x20default\x20for\x20GONOSUMDB\x20and\x20GONOPROXY,\x20so\x20it's\x0anot\x20necessary\x20to\x20set\x20GONOSUMDB\x20unless\x20GONOPROXY\x20should\x20have\x20a\x0adifferent\x20value.

\x0a

A\x20proxy\x20may\x20mirror\x20the\x20checksum\x0adatabase.\x0aIf\x20a\x20proxy\x20in\x20GOPROXY\x20does\x20this,\x20the\x20go\x20command\x20will\x20not\x20connect\x20to\x20the\x0achecksum\x20database\x20directly.

\x0a

GOSUMDB\x20may\x20be\x20set\x20to\x20off\x20to\x20disable\x20use\x20of\x20the\x20checksum\x20database\x0aentirely.\x20With\x20this\x20setting,\x20the\x20go\x20command\x20will\x20not\x20authenticate\x20downloaded\x0amodules\x20unless\x20they're\x20already\x20in\x20go.sum.\x20See\x20Authenticating\x0amodules.

\x0aModule\x20cache\x0a

The\x20module\x20cache\x20is\x20the\x20directory\x20where\x20the\x20go\x20command\x20stores\x0adownloaded\x20module\x20files.\x20The\x20module\x20cache\x20is\x20distinct\x20from\x20the\x20build\x20cache,\x0awhich\x20contains\x20compiled\x20packages\x20and\x20other\x20build\x20artifacts.

\x0a

The\x20default\x20location\x20of\x20the\x20module\x20cache\x20is\x20$GOPATH/pkg/mod.\x20To\x20use\x20a\x0adifferent\x20location,\x20set\x20the\x20GOMODCACHE\x20environment\x0avariable.

\x0a

The\x20module\x20cache\x20has\x20no\x20maximum\x20size,\x20and\x20the\x20go\x20command\x20does\x20not\x20remove\x20its\x0acontents\x20automatically.

\x0a

The\x20cache\x20may\x20be\x20shared\x20by\x20multiple\x20Go\x20projects\x20developed\x20on\x20the\x20same\x20machine.\x0aThe\x20go\x20command\x20will\x20use\x20the\x20same\x20cache\x20regardless\x20of\x20the\x20location\x20of\x20the\x0amain\x20module.\x20Multiple\x20instances\x20of\x20the\x20go\x20command\x20may\x20safely\x20access\x20the\x0asame\x20module\x20cache\x20at\x20the\x20same\x20time.

\x0a

The\x20go\x20command\x20creates\x20module\x20source\x20files\x20and\x20directories\x20in\x20the\x20cache\x20with\x0aread-only\x20permissions\x20to\x20prevent\x20accidental\x20changes\x20to\x20modules\x20after\x20they're\x0adownloaded.\x20This\x20has\x20the\x20unfortunate\x20side-effect\x20of\x20making\x20the\x20cache\x20difficult\x0ato\x20delete\x20with\x20commands\x20like\x20rm\x20-rf.\x20The\x20cache\x20may\x20instead\x20be\x20deleted\x20with\x0ago\x20clean\x20-modcache.\x20Alternatively,\x20when\x20the\x0a-modcacherw\x20flag\x20is\x20used,\x20the\x20go\x20command\x20will\x20create\x20new\x20directories\x20with\x0aread-write\x20permissions.\x20This\x20increases\x20the\x20risk\x20of\x20editors,\x20tests,\x20and\x20other\x0aprograms\x20modifying\x20files\x20in\x20the\x20module\x20cache.\x20The\x20go\x20mod\x20verify\x20command\x20may\x20be\x20used\x20to\x20detect\x20modifications\x20to\x0adependencies\x20of\x20the\x20main\x20module.\x20It\x20scans\x20the\x20extracted\x20contents\x20of\x20each\x0amodule\x20dependency\x20and\x20confirms\x20they\x20match\x20the\x20expected\x20hash\x20in\x20go.sum.

\x0a

The\x20table\x20below\x20explains\x20the\x20purpose\x20of\x20most\x20files\x20in\x20the\x20module\x20cache.\x20Some\x0atransient\x20files\x20(lock\x20files,\x20temporary\x20directories)\x20are\x20omitted.\x20For\x20each\x20path,\x0a$module\x20is\x20a\x20module\x20path,\x20and\x20$version\x20is\x20a\x20version.\x20Paths\x20ending\x20with\x0aslashes\x20(/)\x20are\x20directories.\x20Capital\x20letters\x20in\x20module\x20paths\x20and\x20versions\x20are\x0aescaped\x20using\x20exclamation\x20points\x20(Azure\x20is\x20escaped\x20as\x20!azure)\x20to\x20avoid\x0aconflicts\x20on\x20case-insensitive\x20file\x20systems.

\x0a\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20Path\x0a\x20\x20\x20\x20\x20\x20Description\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$module@$version/\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Directory\x20containing\x20extracted\x20contents\x20of\x20a\x20module\x20.zip\x0a\x20\x20\x20\x20\x20\x20\x20\x20file.\x20This\x20serves\x20as\x20a\x20module\x20root\x20directory\x20for\x20a\x20downloaded\x20module.\x20It\x0a\x20\x20\x20\x20\x20\x20\x20\x20won't\x20contain\x20contain\x20a\x20go.mod\x20file\x20if\x20the\x20original\x20module\x0a\x20\x20\x20\x20\x20\x20\x20\x20didn't\x20have\x20one.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20cache/download/\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Directory\x20containing\x20files\x20downloaded\x20from\x20module\x20proxies\x20and\x20files\x0a\x20\x20\x20\x20\x20\x20\x20\x20derived\x20from\x20version\x20control\x20systems.\x20The\x20layout\x20of\x0a\x20\x20\x20\x20\x20\x20\x20\x20this\x20directory\x20follows\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20GOPROXY\x20protocol,\x20so\x0a\x20\x20\x20\x20\x20\x20\x20\x20this\x20directory\x20may\x20be\x20used\x20as\x20a\x20proxy\x20when\x20served\x20by\x20an\x20HTTP\x20file\x0a\x20\x20\x20\x20\x20\x20\x20\x20server\x20or\x20when\x20referenced\x20with\x20a\x20file://\x20URL.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20cache/download/$module/@v/list\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20List\x20of\x20known\x20versions\x20(see\x0a\x20\x20\x20\x20\x20\x20\x20\x20GOPROXY\x20protocol).\x20This\x0a\x20\x20\x20\x20\x20\x20\x20\x20may\x20change\x20over\x20time,\x20so\x20the\x20go\x20command\x20usually\x20fetches\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20new\x20copy\x20instead\x20of\x20re-using\x20this\x20file.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20cache/download/$module/@v/$version.info\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20JSON\x20metadata\x20about\x20the\x20version.\x20(see\x0a\x20\x20\x20\x20\x20\x20\x20\x20GOPROXY\x20protocol).\x20This\x0a\x20\x20\x20\x20\x20\x20\x20\x20may\x20change\x20over\x20time,\x20so\x20the\x20go\x20command\x20usually\x20fetches\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20new\x20copy\x20instead\x20of\x20re-using\x20this\x20file.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20cache/download/$module/@v/$version.mod\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20The\x20go.mod\x20file\x20for\x20this\x20version\x20(see\x0a\x20\x20\x20\x20\x20\x20\x20\x20GOPROXY\x20protocol).\x20If\x0a\x20\x20\x20\x20\x20\x20\x20\x20the\x20original\x20module\x20did\x20not\x20have\x20a\x20go.mod\x20file,\x20this\x20is\x0a\x20\x20\x20\x20\x20\x20\x20\x20a\x20synthesized\x20file\x20with\x20no\x20requirements.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20cache/download/$module/@v/$version.zip\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20The\x20zipped\x20contents\x20of\x20the\x20module\x20(see\x0a\x20\x20\x20\x20\x20\x20\x20\x20GOPROXY\x20protocol\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20Module\x20zip\x20files).\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20cache/download/$module/@v/$version.ziphash\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20A\x20cryptographic\x20hash\x20of\x20the\x20files\x20in\x20the\x20.zip\x20file.\x0a\x20\x20\x20\x20\x20\x20\x20\x20Note\x20that\x20the\x20.zip\x20file\x20itself\x20is\x20not\x20hashed,\x20so\x20file\x0a\x20\x20\x20\x20\x20\x20\x20\x20order,\x20compression,\x20alignment,\x20and\x20metadata\x20don't\x20affect\x20the\x20hash.\x0a\x20\x20\x20\x20\x20\x20\x20\x20When\x20using\x20a\x20module,\x20the\x20go\x20command\x20verifies\x20this\x20hash\x0a\x20\x20\x20\x20\x20\x20\x20\x20matches\x20the\x20corresponding\x20line\x20in\x0a\x20\x20\x20\x20\x20\x20\x20\x20go.sum.\x20The\x0a\x20\x20\x20\x20\x20\x20\x20\x20go\x20mod\x20verify\x20command\x20checks\x0a\x20\x20\x20\x20\x20\x20\x20\x20that\x20the\x20hashes\x20of\x20module\x20.zip\x20files\x20and\x20extracted\x0a\x20\x20\x20\x20\x20\x20\x20\x20directories\x20match\x20these\x20files.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20cache/download/sumdb/\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Directory\x20containing\x20files\x20downloaded\x20from\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20checksum\x20database\x20(typically\x0a\x20\x20\x20\x20\x20\x20\x20\x20sum.golang.org).\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20cache/vcs/\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Contains\x20cloned\x20version\x20control\x20repositories\x20for\x20modules\x20fetched\x0a\x20\x20\x20\x20\x20\x20\x20\x20directly\x20from\x20their\x20sources.\x20Directory\x20names\x20are\x20hex-encoded\x20hashes\x0a\x20\x20\x20\x20\x20\x20\x20\x20derived\x20from\x20the\x20repository\x20type\x20and\x20URL.\x20Repositories\x20are\x20optimized\x0a\x20\x20\x20\x20\x20\x20\x20\x20for\x20size\x20on\x20disk.\x20For\x20example,\x20cloned\x20Git\x20repositories\x20are\x20bare\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20shallow\x20when\x20possible.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x0aAuthenticating\x20modules\x0a\x0a

When\x20deciding\x20whether\x20to\x20trust\x20the\x20source\x20code\x20for\x20a\x20module\x20version\x20just\x0afetched\x20from\x20a\x20proxy\x20or\x20origin\x20server,\x20the\x20go\x20command\x20first\x20consults\x20the\x0ago.sum\x20lines\x20in\x20the\x20go.sum\x20file\x20of\x20the\x20current\x20module.\x20If\x20the\x20go.sum\x20file\x0adoes\x20not\x20contain\x20an\x20entry\x20for\x20that\x20module\x20version,\x20then\x20it\x20may\x20consult\x20the\x0achecksum\x20database.

\x0ago.sum\x20files\x0a

A\x20module\x20may\x20have\x20a\x20text\x20file\x20named\x20go.sum\x20in\x20its\x20root\x20directory,\x20alongside\x0aits\x20go.mod\x20file.\x20The\x20go.sum\x20file\x20contains\x20cryptographic\x20hashes\x20of\x20the\x0amodule's\x20direct\x20and\x20indirect\x20dependencies.\x20go.sum\x20may\x20be\x20empty\x20or\x20absent\x0aif\x20the\x20module\x20has\x20no\x20dependencies\x20or\x20if\x20all\x20dependencies\x20are\x20replaced\x20with\x0alocal\x20directories\x20using\x20replace\x20directives.

\x0a

Each\x20line\x20in\x20go.sum\x20has\x20three\x20fields\x20separated\x20by\x20spaces:\x20a\x20module\x20path,\x0aa\x20version\x20(possibly\x20ending\x20with\x20/go.mod),\x20and\x20a\x20hash.

\x0a
    \x0a
  • The\x20module\x20path\x20is\x20the\x20name\x20of\x20the\x20module\x20the\x20hash\x20belongs\x20to.
  • \x0a
  • The\x20version\x20is\x20the\x20version\x20of\x20the\x20module\x20the\x20hash\x20belongs\x20to.\x20If\x20the\x20version\x0aends\x20with\x20/go.mod,\x20the\x20hash\x20is\x20for\x20the\x20module's\x20go.mod\x20file\x20only;\x0aotherwise,\x20the\x20hash\x20is\x20for\x20the\x20files\x20within\x20the\x20module's\x20.zip\x20file.
  • \x0a
  • The\x20hash\x20column\x20consists\x20of\x20an\x20algorithm\x20name\x20(like\x20h1)\x20and\x20a\x20base64-encoded\x0acryptographic\x20hash,\x20separated\x20by\x20a\x20colon\x20(:).\x20Currently,\x20SHA-256\x20(h1)\x20is\x0athe\x20only\x20supported\x20hash\x20algorithm.\x20If\x20a\x20vulnerability\x20in\x20SHA-256\x20is\x20discovered\x0ain\x20the\x20future,\x20support\x20will\x20be\x20added\x20for\x20another\x20algorithm\x20(named\x20h2\x20and\x0aso\x20on).
  • \x0a
\x0a

When\x20the\x20go\x20command\x20downloads\x20a\x20module\x20.mod\x20or\x20.zip\x20file\x20into\x20the\x20module\x0acache,\x20it\x20computes\x20a\x20hash\x20and\x20checks\x20that\x20the\x20hash\x20matches\x20the\x0acorresponding\x20hash\x20in\x20the\x20main\x20module's\x20go.sum\x20file.\x20For\x20.mod\x20files,\x20the\x0afile\x20contents\x20are\x20hashed.\x20For\x20.zip\x20files,\x20the\x20files\x20within\x20the\x20archive\x20are\x0ahashed.\x20The\x20hash\x20is\x20not\x20affected\x20by\x20file\x20ordering,\x20compression,\x20alignment,\x20or\x0ametadata.\x20See\x20Module\x20zip\x20files\x20for\x20information\x20on\x20which\x20files\x20are\x0aincluded.\x20See\x0agolang.org/x/mod/sumdb/dirhash\x0afor\x20hash\x20implementation\x20details.

\x0a

If\x20the\x20computed\x20hash\x20does\x20not\x20match\x20the\x20corresponding\x20hash\x20in\x20go.sum,\x20the\x20go\x0acommand\x20reports\x20a\x20security\x20error.\x20If\x20the\x20hash\x20is\x20not\x20present\x20in\x20go.sum,\x20the\x0ago\x20command\x20looks\x20up\x20the\x20correct\x20hash\x20in\x20the\x20checksum\x0adatabase\x20(unless\x20the\x20module\x20matches\x20GONOSUMDB\x20or\x0aGOSUMDB\x20is\x20set\x20to\x20off;\x20see\x20Environment\x0avariables).\x20If\x20no\x20mismatch\x20is\x20detected,\x20the\x20go\x0acommand\x20adds\x20the\x20hash\x20to\x20go.sum.

\x0a

The\x20go\x20command\x20does\x20not\x20automatically\x20verify\x20modules\x20already\x20in\x20the\x20cache.\x20By\x0adefault,\x20files\x20and\x20directories\x20in\x20the\x20module\x20cache\x20have\x20read-only\x20permissions\x20to\x0aprevent\x20accidental\x20changes.\x20The\x20go\x20mod\x20verify\x20command\x20may\x20be\x0aused\x20to\x20check\x20that\x20.zip\x20files\x20and\x20extracted\x20directories\x20in\x20the\x20module\x20cache\x0amatch\x20hashes\x20recorded\x20when\x20they\x20were\x20downloaded.

\x0a

The\x20go.sum\x20file\x20may\x20contain\x20hashes\x20for\x20multiple\x20versions\x20of\x20a\x20module.\x20The\x20go\x0acommand\x20may\x20need\x20to\x20load\x20go.mod\x20files\x20from\x20multiple\x20versions\x20of\x20a\x20dependency\x0ain\x20order\x20to\x20perform\x20minimal\x20version\x20selection.\x0ago.sum\x20may\x20also\x20contain\x20hashes\x20for\x20module\x20versions\x20that\x20aren't\x20needed\x20anymore\x0a(for\x20example,\x20after\x20an\x20upgrade).\x20go\x20mod\x20tidy\x20will\x20add\x20missing\x0ahashes\x20and\x20will\x20remove\x20unnecessary\x20hashes\x20from\x20go.sum.

\x0aChecksum\x20database\x0a

The\x20checksum\x20database\x20is\x20a\x20global\x20source\x20of\x20go.sum\x20lines.\x20The\x20go\x20command\x20can\x0ause\x20this\x20in\x20many\x20situations\x20to\x20detect\x20misbehavior\x20by\x20proxies\x20or\x20origin\x20servers.

\x0a

The\x20checksum\x20database\x20allows\x20for\x20global\x20consistency\x20and\x20reliability\x20for\x20all\x0apublicly\x20available\x20module\x20versions.\x20It\x20makes\x20untrusted\x20proxies\x20possible\x20since\x0athey\x20can't\x20serve\x20the\x20wrong\x20code\x20without\x20it\x20going\x20unnoticed.\x20It\x20also\x20ensures\x0athat\x20the\x20bits\x20associated\x20with\x20a\x20specific\x20version\x20do\x20not\x20change\x20from\x20one\x20day\x20to\x0athe\x20next,\x20even\x20if\x20the\x20module's\x20author\x20subsequently\x20alters\x20the\x20tags\x20in\x20their\x0arepository.

\x0a

The\x20checksum\x20database\x20is\x20served\x20by\x20sum.golang.org,\x0awhich\x20is\x20run\x20by\x20Google.\x20It\x20is\x20a\x20Transparent\x0aLog\x20(or\x20\xe2\x80\x9cMerkle\x20Tree\xe2\x80\x9d)\x20of\x20go.sum\x20line\x0ahashes,\x20which\x20is\x20backed\x20by\x20Trillian.\x20The\x0amain\x20advantage\x20of\x20a\x20Merkle\x20tree\x20is\x20that\x20independent\x20auditors\x20can\x20verify\x20that\x20it\x0ahasn't\x20been\x20tampered\x20with,\x20so\x20it\x20is\x20more\x20trustworthy\x20than\x20a\x20simple\x20database.

\x0a

The\x20go\x20command\x20interacts\x20with\x20the\x20checksum\x20database\x20using\x20the\x20protocol\x0aoriginally\x20outlined\x20in\x20Proposal:\x20Secure\x20the\x20Public\x20Go\x20Module\x0aEcosystem.

\x0a

The\x20table\x20below\x20specifies\x20queries\x20that\x20the\x20checksum\x20database\x20must\x20respond\x20to.\x0aFor\x20each\x20path,\x20$base\x20is\x20the\x20path\x20portion\x20of\x20the\x20checksum\x20database\x20URL,\x0a$module\x20is\x20a\x20module\x20path,\x20and\x20$version\x20is\x20a\x20version.\x20For\x20example,\x20if\x20the\x0achecksum\x20database\x20URL\x20is\x20https://sum.golang.org,\x20and\x20the\x20client\x20is\x20requesting\x0athe\x20record\x20for\x20the\x20module\x20golang.org/x/text\x20at\x20version\x20v0.3.2,\x20the\x20client\x0awould\x20send\x20a\x20GET\x20request\x20for\x0ahttps://sum.golang.org/lookup/golang.org/x/text@v0.3.2.

\x0a

To\x20avoid\x20ambiguity\x20when\x20serving\x20from\x20case-insensitive\x20file\x20systems,\x0athe\x20$module\x20and\x20$version\x20elements\x20are\x0acase-encoded\x0aby\x20replacing\x20every\x20uppercase\x20letter\x20with\x20an\x20exclamation\x20mark\x20followed\x20by\x20the\x0acorresponding\x20lower-case\x20letter.\x20This\x20allows\x20modules\x20example.com/M\x20and\x0aexample.com/m\x20to\x20both\x20be\x20stored\x20on\x20disk,\x20since\x20the\x20former\x20is\x20encoded\x20as\x0aexample.com/!m.

\x0a

Parts\x20of\x20the\x20path\x20surrounded\x20by\x20square\x20brakets,\x20like\x20[.p/$W]\x20denote\x20optional\x0avalues.

\x0a\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20Path\x0a\x20\x20\x20\x20\x20\x20Description\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$base/latest\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Returns\x20a\x20signed,\x20encoded\x20tree\x20description\x20for\x20the\x20latest\x20log.\x20This\x0a\x20\x20\x20\x20\x20\x20\x20\x20signed\x20description\x20is\x20in\x20the\x20form\x20of\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20note,\x0a\x20\x20\x20\x20\x20\x20\x20\x20which\x20is\x20text\x20that\x20has\x20been\x20signed\x20by\x20one\x20or\x20more\x20server\x20keys\x20and\x20can\x0a\x20\x20\x20\x20\x20\x20\x20\x20be\x20verified\x20using\x20the\x20server's\x20public\x20key.\x20The\x20tree\x20description\x0a\x20\x20\x20\x20\x20\x20\x20\x20provides\x20the\x20size\x20of\x20the\x20tree\x20and\x20the\x20hash\x20of\x20the\x20tree\x20head\x20at\x20that\x0a\x20\x20\x20\x20\x20\x20\x20\x20size.\x20This\x20encoding\x20is\x20described\x20in\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20golang.org/x/mod/sumdb/tlog#FormatTree.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$base/lookup/$module@$version\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Returns\x20the\x20log\x20record\x20number\x20for\x20the\x20entry\x20about\x20$module\x0a\x20\x20\x20\x20\x20\x20\x20\x20at\x20$version,\x20followed\x20by\x20the\x20data\x20for\x20the\x20record\x20(that\x20is,\x0a\x20\x20\x20\x20\x20\x20\x20\x20the\x20go.sum\x20lines\x20for\x20$module\x20at\x0a\x20\x20\x20\x20\x20\x20\x20\x20$version)\x20and\x20a\x20signed,\x20encoded\x20tree\x20description\x20that\x0a\x20\x20\x20\x20\x20\x20\x20\x20contains\x20the\x20record.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$base/tile/$H/$L/$K[.p/$W]\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Returns\x20a\x20[log\x20tile](https://research.swtch.com/tlog#serving_tiles),\x0a\x20\x20\x20\x20\x20\x20\x20\x20which\x20is\x20a\x20set\x20of\x20hashes\x20that\x20make\x20up\x20a\x20section\x20of\x20the\x20log.\x20Each\x20tile\x0a\x20\x20\x20\x20\x20\x20\x20\x20is\x20defined\x20in\x20a\x20two-dimensional\x20coordinate\x20at\x20tile\x20level\x0a\x20\x20\x20\x20\x20\x20\x20\x20$L,\x20$Kth\x20from\x20the\x20left,\x20with\x20a\x20tile\x20height\x20of\x0a\x20\x20\x20\x20\x20\x20\x20\x20$H.\x20The\x20optional\x20.p/$W\x20suffix\x20indicates\x20a\x0a\x20\x20\x20\x20\x20\x20\x20\x20partial\x20log\x20tile\x20with\x20only\x20$W\x20hashes.\x20Clients\x20must\x20fall\x0a\x20\x20\x20\x20\x20\x20\x20\x20back\x20to\x20fetching\x20the\x20full\x20tile\x20if\x20a\x20partial\x20tile\x20is\x20not\x20found.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20$base/tile/$H/data/$K[.p/$W]\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Returns\x20the\x20record\x20data\x20for\x20the\x20leaf\x20hashes\x20in\x0a\x20\x20\x20\x20\x20\x20\x20\x20/tile/$H/0/$K[.p/$W]\x20(with\x20a\x20literal\x20data\x20path\x0a\x20\x20\x20\x20\x20\x20\x20\x20element).\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x0a

If\x20the\x20go\x20command\x20consults\x20the\x20checksum\x20database,\x20then\x20the\x20first\x0astep\x20is\x20to\x20retrieve\x20the\x20record\x20data\x20through\x20the\x20/lookup\x20endpoint.\x20If\x20the\x0amodule\x20version\x20is\x20not\x20yet\x20recorded\x20in\x20the\x20log,\x20the\x20checksum\x20database\x20will\x20try\x0ato\x20fetch\x20it\x20from\x20the\x20origin\x20server\x20before\x20replying.\x20This\x20/lookup\x20data\x0aprovides\x20the\x20sum\x20for\x20this\x20module\x20version\x20as\x20well\x20as\x20its\x20position\x20in\x20the\x20log,\x0awhich\x20informs\x20the\x20client\x20of\x20which\x20tiles\x20should\x20be\x20fetched\x20to\x20perform\x20proofs.\x0aThe\x20go\x20command\x20performs\x20\xe2\x80\x9cinclusion\xe2\x80\x9d\x20proofs\x20(that\x20a\x20specific\x20record\x20exists\x20in\x0athe\x20log)\x20and\x20\xe2\x80\x9cconsistency\xe2\x80\x9d\x20proofs\x20(that\x20the\x20tree\x20hasn\xe2\x80\x99t\x20been\x20tampered\x20with)\x0abefore\x20adding\x20new\x20go.sum\x20lines\x20to\x20the\x20main\x20module\xe2\x80\x99s\x20go.sum\x20file.\x20It's\x0aimportant\x20that\x20the\x20data\x20from\x20/lookup\x20should\x20never\x20be\x20used\x20without\x20first\x0aauthenticating\x20it\x20against\x20the\x20signed\x20tree\x20hash\x20and\x20authenticating\x20the\x20signed\x0atree\x20hash\x20against\x20the\x20client's\x20timeline\x20of\x20signed\x20tree\x20hashes.

\x0a

Signed\x20tree\x20hashes\x20and\x20new\x20tiles\x20served\x20by\x20the\x20checksum\x20database\x20are\x20stored\x0ain\x20the\x20module\x20cache,\x20so\x20the\x20go\x20command\x20only\x20needs\x20to\x20fetch\x20tiles\x20that\x20are\x0amissing.

\x0a

The\x20go\x20command\x20doesn't\x20need\x20to\x20directly\x20connect\x20to\x20the\x20checksum\x20database.\x20It\x0acan\x20request\x20module\x20sums\x20via\x20a\x20module\x20proxy\x20that\x0amirrors\x20the\x20checksum\x20database\x0aand\x20supports\x20the\x20protocol\x20above.\x20This\x20can\x20be\x20particularly\x20helpful\x20for\x20private,\x0acorporate\x20proxies\x20which\x20block\x20requests\x20outside\x20the\x20organization.

\x0a

The\x20GOSUMDB\x20environment\x20variable\x20identifies\x20the\x20name\x20of\x20checksum\x20database\x20to\x20use\x0aand\x20optionally\x20its\x20public\x20key\x20and\x20URL,\x20as\x20in:

\x0a
GOSUMDB="sum.golang.org"\x0aGOSUMDB="sum.golang.org+<publickey>"\x0aGOSUMDB="sum.golang.org+<publickey>\x20https://sum.golang.org"\x0a
\x0a

The\x20go\x20command\x20knows\x20the\x20public\x20key\x20of\x20sum.golang.org,\x20and\x20also\x20that\x20the\x0aname\x20sum.golang.google.cn\x20(available\x20inside\x20mainland\x20China)\x20connects\x20to\x20the\x0asum.golang.org\x20checksum\x20database;\x20use\x20of\x20any\x20other\x20database\x20requires\x20giving\x0athe\x20public\x20key\x20explicitly.\x20The\x20URL\x20defaults\x20to\x20https://\x20followed\x20by\x20the\x0adatabase\x20name.

\x0a

GOSUMDB\x20defaults\x20to\x20sum.golang.org,\x20the\x20Go\x20checksum\x20database\x20run\x20by\x20Google.\x0aSee\x20https://sum.golang.org/privacy\x20for\x20the\x20service's\x20privacy\x20policy.

\x0a

If\x20GOSUMDB\x20is\x20set\x20to\x20off,\x20or\x20if\x20go\x20get\x20is\x20invoked\x20with\x20the\x20-insecure\x0aflag,\x20the\x20checksum\x20database\x20is\x20not\x20consulted,\x20and\x20all\x20unrecognized\x20modules\x20are\x0aaccepted,\x20at\x20the\x20cost\x20of\x20giving\x20up\x20the\x20security\x20guarantee\x20of\x20verified\x0arepeatable\x20downloads\x20for\x20all\x20modules.\x20A\x20better\x20way\x20to\x20bypass\x20the\x20checksum\x0adatabase\x20for\x20specific\x20modules\x20is\x20to\x20use\x20the\x20GOPRIVATE\x20or\x20GONOSUMDB\x0aenvironment\x20variables.\x20See\x20Private\x20Modules\x20for\x20details.

\x0a

The\x20go\x20env\x20-w\x20command\x20can\x20be\x20used\x20to\x0aset\x20these\x20variables\x0afor\x20future\x20go\x20command\x20invocations.

\x0aEnvironment\x20variables\x0a

Module\x20behavior\x20in\x20the\x20go\x20command\x20may\x20be\x20configured\x20using\x20the\x20environment\x0avariables\x20listed\x20below.\x20This\x20list\x20only\x20includes\x20module-related\x20environment\x0avariables.\x20See\x20go\x20help\x20environment\x20for\x20a\x20list\x0aof\x20all\x20environment\x20variables\x20recognized\x20by\x20the\x20go\x20command.

\x0a\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20Variable\x0a\x20\x20\x20\x20\x20\x20Description\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20GO111MODULE\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Controls\x20whether\x20the\x20go\x20command\x20runs\x20in\x20module-aware\x20mode\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20or\x20GOPATH\x20mode.\x20Three\x20values\x20are\x20recognized:\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20
    \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20off:\x20the\x20go\x20command\x20ignores\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20go.mod\x20files\x20and\x20runs\x20in\x20GOPATH\x20mode.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20on:\x20the\x20go\x20command\x20runs\x20in\x20module-aware\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20mode,\x20even\x20when\x20no\x20go.mod\x20file\x20is\x20present.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20auto\x20(or\x20unset):\x20the\x20go\x20command\x20runs\x20in\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module-aware\x20mode\x20if\x20a\x20go.mod\x20file\x20is\x20present\x20in\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20current\x20directory\x20or\x20any\x20parent\x20directory\x20(the\x20default\x20behavior).\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20
\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20See\x20Module-aware\x20commands\x20for\x20more\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20information.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20GOMODCACHE\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20The\x20directory\x20where\x20the\x20go\x20command\x20will\x20store\x20downloaded\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20modules\x20and\x20related\x20files.\x20See\x20Module\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20cache\x20for\x20details\x20on\x20the\x20structure\x20of\x20this\x20directory.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20If\x20GOMODCACHE\x20is\x20not\x20set,\x20it\x20defaults\x20to\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20$GOPATH/pkg/mod.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20GOINSECURE\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Comma-separated\x20list\x20of\x20glob\x20patterns\x20(in\x20the\x20syntax\x20of\x20Go's\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20path.Match)\x20of\x20module\x20path\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20prefixes\x20that\x20may\x20always\x20be\x20fetched\x20in\x20an\x20insecure\x20manner.\x20Only\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20applies\x20to\x20dependencies\x20that\x20are\x20being\x20fetched\x20directly.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Unlike\x20the\x20-insecure\x20flag\x20on\x20go\x20get,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20GOINSECURE\x20does\x20not\x20disable\x20module\x20checksum\x20database\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20validation.\x20GOPRIVATE\x20or\x20GONOSUMDB\x20may\x20be\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20used\x20to\x20achieve\x20that.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20GONOPROXY\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Comma-separated\x20list\x20of\x20glob\x20patterns\x20(in\x20the\x20syntax\x20of\x20Go's\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20path.Match)\x20of\x20module\x20path\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20prefixes\x20that\x20should\x20always\x20be\x20fetched\x20directly\x20from\x20version\x20control\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20repositories,\x20not\x20from\x20module\x20proxies.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20If\x20GONOPROXY\x20is\x20not\x20set,\x20it\x20defaults\x20to\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20GOPRIVATE.\x20See\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Privacy.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20GONOSUMDB\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Comma-separated\x20list\x20of\x20glob\x20patterns\x20(in\x20the\x20syntax\x20of\x20Go's\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20path.Match)\x20of\x20module\x20path\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20prefixes\x20for\x20which\x20the\x20go\x20should\x20not\x20verify\x20checksums\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20using\x20the\x20checksum\x20database.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20If\x20GONOSUMDB\x20is\x20not\x20set,\x20it\x20defaults\x20to\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20GOPRIVATE.\x20See\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Privacy.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20GOPATH\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20In\x20GOPATH\x20mode,\x20the\x20GOPATH\x20variable\x20is\x20a\x20list\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20of\x20directories\x20that\x20may\x20contain\x20Go\x20code.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20In\x20module-aware\x20mode,\x20the\x20module\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20cache\x20is\x20stored\x20in\x20the\x20pkg/mod\x20subdirectory\x20of\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20first\x20GOPATH\x20directory.\x20Module\x20source\x20code\x20outside\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20cache\x20may\x20be\x20stored\x20in\x20any\x20directory.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20If\x20GOPATH\x20is\x20not\x20set,\x20it\x20defaults\x20to\x20the\x20go\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20subdirectory\x20of\x20the\x20user's\x20home\x20directory.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20GOPRIVATE\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20Comma-separated\x20list\x20of\x20glob\x20patterns\x20(in\x20the\x20syntax\x20of\x20Go's\x0a\x20\x20\x20\x20\x20\x20\x20\x20path.Match)\x20of\x20module\x20path\x0a\x20\x20\x20\x20\x20\x20\x20\x20prefixes\x20that\x20should\x20be\x20considered\x20private.\x20GOPRIVATE\x0a\x20\x20\x20\x20\x20\x20\x20\x20is\x20a\x20default\x20value\x20for\x20GONOPROXY\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20GONOSUMDB.\x20GOPRIVATE\x20itself\x20has\x20no\x20other\x0a\x20\x20\x20\x20\x20\x20\x20\x20meaning.\x20See\x20Privacy.\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20GOPROXY\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20List\x20of\x20module\x20proxy\x20URLs,\x20separated\x20by\x20commas\x20(,)\x20or\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20pipes\x20(|).\x20When\x20the\x20go\x20command\x20looks\x20up\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20information\x20about\x20a\x20module,\x20it\x20contacts\x20each\x20proxy\x20in\x20the\x20list\x20in\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20sequence\x20until\x20it\x20receives\x20a\x20successful\x20response\x20or\x20a\x20terminal\x20error.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20A\x20proxy\x20may\x20respond\x20with\x20a\x20404\x20(Not\x20Found)\x20or\x20410\x20(Gone)\x20status\x20to\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20indicate\x20the\x20module\x20is\x20not\x20available\x20on\x20that\x20server.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20The\x20go\x20command's\x20error\x20fallback\x20behavior\x20is\x20determined\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20by\x20the\x20separator\x20characters\x20between\x20URLs.\x20If\x20a\x20proxy\x20URL\x20is\x20followed\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20by\x20a\x20comma,\x20the\x20go\x20command\x20falls\x20back\x20to\x20the\x20next\x20URL\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20after\x20a\x20404\x20or\x20410\x20error;\x20all\x20other\x20errors\x20are\x20considered\x20terminal.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20If\x20the\x20proxy\x20URL\x20is\x20followed\x20by\x20a\x20pipe,\x20the\x20go\x20command\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20falls\x20back\x20to\x20the\x20next\x20source\x20after\x20any\x20error,\x20including\x20non-HTTP\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20errors\x20like\x20timeouts.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20GOPROXY\x20URLs\x20may\x20have\x20the\x20schemes\x20https,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20http,\x20or\x20file.\x20If\x20a\x20URL\x20has\x20no\x20scheme,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20https\x20is\x20assumed.\x20A\x20module\x20cache\x20may\x20be\x20used\x20direclty\x20as\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20a\x20file\x20proxy:\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20
GOPROXY=file://$(go\x20env\x20GOMODCACHE)/cache/download
\x0a\x20\x20\x20\x20\x20\x20\x20\x20

Two\x20keywords\x20may\x20be\x20used\x20in\x20place\x20of\x20proxy\x20URLs:

\x0a\x20\x20\x20\x20\x20\x20\x20\x20
    \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20off:\x20disallows\x20downloading\x20modules\x20from\x20any\x20source.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20direct:\x20download\x20directly\x20from\x20version\x20control\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20repositories\x20instead\x20of\x20using\x20a\x20module\x20proxy.\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
  • \x0a\x20\x20\x20\x20\x20\x20\x20\x20
\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20GOPROXY\x20defaults\x20to\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20https://proxy.golang.org,direct.\x20Under\x20that\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20configuration,\x20the\x20go\x20command\x20first\x20contacts\x20the\x20Go\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20module\x20mirror\x20run\x20by\x20Google,\x20then\x20falls\x20back\x20to\x20a\x20direct\x20connection\x20if\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20the\x20mirror\x20does\x20not\x20have\x20the\x20module.\x20See\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20https://proxy.golang.org/privacy\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20for\x20the\x20mirror's\x20privacy\x20policy.\x20The\x20GOPRIVATE\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20GONOPROXY\x20environment\x20variables\x20may\x20be\x20set\x20to\x20prevent\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20specific\x20modules\x20from\x20being\x20downloaded\x20using\x20proxies.\x20See\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Privacy\x20for\x20information\x20on\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20private\x20proxy\x20configuration.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20See\x20Module\x20proxies\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Resolving\x20a\x20package\x20to\x20a\x20module\x20for\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20more\x20information\x20on\x20how\x20proxies\x20are\x20used.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20GOSUMDB\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Identifies\x20the\x20name\x20of\x20the\x20checksum\x20database\x20to\x20use\x20and\x20optionally\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20its\x20public\x20key\x20and\x20URL.\x20For\x20example:\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20
\x0aGOSUMDB=\"sum.golang.org\"\x0aGOSUMDB=\"sum.golang.org+<publickey>\"\x0aGOSUMDB=\"sum.golang.org+<publickey>\x20https://sum.golang.org\x0a
\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20The\x20go\x20command\x20knows\x20the\x20public\x20key\x20of\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20sum.golang.org\x20and\x20also\x20that\x20the\x20name\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20sum.golang.google.cn\x20(available\x20inside\x20mainland\x20China)\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20connects\x20to\x20the\x20sum.golang.org\x20database;\x20use\x20of\x20any\x20other\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20database\x20requires\x20giving\x20the\x20public\x20key\x20explicitly.\x20The\x20URL\x20defaults\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20to\x20https://\x20followed\x20by\x20the\x20database\x20name.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20GOSUMDB\x20defaults\x20to\x20sum.golang.org,\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Go\x20checksum\x20database\x20run\x20by\x20Google.\x20See\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20https://sum.golang.org/privacy\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20for\x20the\x20service's\x20privacy\x20policy.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20If\x20GOSUMDB\x20is\x20set\x20to\x20off\x20or\x20if\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20go\x20get\x20is\x20invoked\x20with\x20the\x20-insecure\x20flag,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20the\x20checksum\x20database\x20is\x20not\x20consulted,\x20and\x20all\x20unrecognized\x20modules\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20are\x20accepted,\x20at\x20the\x20cost\x20of\x20giving\x20up\x20the\x20security\x20guarantee\x20of\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20verified\x20repeatable\x20downloads\x20for\x20all\x20modules.\x20A\x20better\x20way\x20to\x20bypass\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20the\x20checksum\x20database\x20for\x20specific\x20modules\x20is\x20to\x20use\x20the\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20GOPRIVATE\x20or\x20GONOSUMDB\x20environment\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20variables.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20See\x20Authenticating\x20modules\x20and\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Privacy\x20for\x20more\x20information.\x0a\x20\x20\x20\x20\x20\x20\x20\x20

\x0a\x20\x20\x20\x20\x20\x20\x0a\x20\x20\x20\x20\x0a\x20\x20\x0a\x0aGlossary\x0a

\x0abuild\x20constraint:\x20A\x20condition\x20that\x20determines\x20whether\x20a\x20Go\x20source\x20file\x20is\x0aused\x20when\x20compiling\x20a\x20package.\x20Build\x20constraints\x20may\x20be\x20expressed\x20with\x20file\x20name\x0asuffixes\x20(for\x20example,\x20foo_linux_amd64.go)\x20or\x20with\x20build\x20constraint\x20comments\x0a(for\x20example,\x20//\x20+build\x20linux,amd64).\x20See\x20Build\x0aConstraints.

\x0a

\x0abuild\x20list:\x20The\x20list\x20of\x20module\x20versions\x20that\x20will\x20be\x20used\x20for\x20a\x20build\x0acommand\x20such\x20as\x20go\x20build,\x20go\x20list,\x20or\x20go\x20test.\x20The\x20build\x20list\x20is\x0adetermined\x20from\x20the\x20main\x20module's\x20go.mod\x0afile\x20and\x20go.mod\x20files\x20in\x20transitively\x20required\x20modules\x0ausing\x20minimal\x20version\x20selection.\x20The\x20build\x0alist\x20contains\x20versions\x20for\x20all\x20modules\x20in\x20the\x20module\x0agraph,\x20not\x20just\x20those\x20relevant\x20to\x20a\x20specific\x20command.

\x0a

\x0acanonical\x20version:\x20A\x20correctly\x20formatted\x20version\x20without\x0aa\x20build\x20metadata\x20suffix\x20other\x20than\x20+incompatible.\x20For\x20example,\x20v1.2.3\x0ais\x20a\x20canonical\x20version,\x20but\x20v1.2.3+meta\x20is\x20not.

\x0a

\x0ago.mod\x20file:\x20The\x20file\x20that\x20defines\x20a\x20module's\x20path,\x20requirements,\x20and\x0aother\x20metadata.\x20Appears\x20in\x20the\x20module's\x20root\x0adirectory.\x20See\x20the\x20section\x20on\x20go.mod\x0afiles.

\x0a

\x0aimport\x20path:\x20A\x20string\x20used\x20to\x20import\x20a\x20package\x20in\x20a\x20Go\x20source\x20file.\x0aSynonymous\x20with\x20package\x20path.

\x0a

\x0amain\x20module:\x20The\x20module\x20in\x20which\x20the\x20go\x20command\x20is\x20invoked.

\x0a

\x0amajor\x20version:\x20The\x20first\x20number\x20in\x20a\x20semantic\x20version\x20(1\x20in\x20v1.2.3).\x20In\x0aa\x20release\x20with\x20incompatible\x20changes,\x20the\x20major\x20version\x20must\x20be\x20incremented,\x20and\x0athe\x20minor\x20and\x20patch\x20versions\x20must\x20be\x20set\x20to\x200.\x20Semantic\x20versions\x20with\x20major\x0aversion\x200\x20are\x20considered\x20unstable.

\x0a

\x0amajor\x20version\x20subdirectory:\x20A\x20subdirectory\x20within\x20a\x20version\x20control\x0arepository\x20matching\x20a\x20module's\x20major\x20version\x0asuffix\x20where\x20a\x20module\x20may\x20be\x20defined.\x20For\x20example,\x0athe\x20module\x20example.com/mod/v2\x20in\x20the\x20repository\x20with\x20root\x0apath\x20example.com/mod\x20may\x20be\x20defined\x20in\x20the\x0arepository\x20root\x20directory\x20or\x20the\x20major\x20version\x20subdirectory\x20v2.\x20See\x20Module\x0adirectories\x20within\x20a\x20repository.

\x0a

\x0amajor\x20version\x20suffix:\x20A\x20module\x20path\x20suffix\x20that\x20matches\x20the\x20major\x20version\x0anumber.\x20For\x20example,\x20/v2\x20in\x20example.com/mod/v2.\x20Major\x20version\x20suffixes\x20are\x0arequired\x20at\x20v2.0.0\x20and\x20later\x20and\x20are\x20not\x20allowed\x20at\x20earlier\x20versions.\x20See\x0athe\x20section\x20on\x20Major\x20version\x20suffixes.

\x0a

\x0aminimal\x20version\x20selection\x20(MVS):\x20The\x20algorithm\x20used\x20to\x20determine\x20the\x0aversions\x20of\x20all\x20modules\x20that\x20will\x20be\x20used\x20in\x20a\x20build.\x20See\x20the\x20section\x20on\x0aMinimal\x20version\x20selection\x20for\x20details.

\x0a

\x0aminor\x20version:\x20The\x20second\x20number\x20in\x20a\x20semantic\x20version\x20(2\x20in\x20v1.2.3).\x20In\x0aa\x20release\x20with\x20new,\x20backwards\x20compatible\x20functionality,\x20the\x20minor\x20version\x20must\x0abe\x20incremented,\x20and\x20the\x20patch\x20version\x20must\x20be\x20set\x20to\x200.

\x0a

\x0amodule:\x20A\x20collection\x20of\x20packages\x20that\x20are\x20released,\x20versioned,\x20and\x0adistributed\x20together.

\x0a

\x0amodule\x20cache:\x20A\x20local\x20directory\x20storing\x20downloaded\x20modules,\x20located\x20in\x0aGOPATH/pkg/mod.\x20See\x20Module\x20cache.

\x0a

\x0amodule\x20graph:\x20The\x20directed\x20graph\x20of\x20module\x20requirements,\x20rooted\x20at\x20the\x20main\x0amodule.\x20Each\x20vertex\x20in\x20the\x20graph\x20is\x20a\x20module;\x20each\x20edge\x20is\x20a\x0aversion\x20from\x20a\x20require\x20statement\x20in\x20a\x20go.mod\x20file\x20(subject\x20to\x20replace\x20and\x0aexclude\x20statements\x20in\x20the\x20main\x20module's\x20go.mod\x20file.

\x0a

\x0amodule\x20path:\x20A\x20path\x20that\x20identifies\x20a\x20module\x20and\x20acts\x20as\x20a\x20prefix\x20for\x0apackage\x20import\x20paths\x20within\x20the\x20module.\x20For\x20example,\x20"golang.org/x/net".

\x0a

\x0amodule\x20proxy:\x20A\x20web\x20server\x20that\x20implements\x20the\x20GOPROXY\x0aprotocol.\x20The\x20go\x20command\x20downloads\x20version\x20information,\x0ago.mod\x20files,\x20and\x20module\x20zip\x20files\x20from\x20module\x20proxies.

\x0a

\x0amodule\x20root\x20directory:\x20The\x20directory\x20that\x20contains\x20the\x20go.mod\x20file\x20that\x0adefines\x20a\x20module.

\x0a

\x0amodule\x20subdirectory:\x20The\x20portion\x20of\x20a\x20module\x20path\x20after\x0athe\x20repository\x20root\x20path\x20that\x20indicates\x20the\x0asubdirectory\x20where\x20the\x20module\x20is\x20defined.\x20When\x20non-empty,\x20the\x20module\x0asubdirectory\x20is\x20also\x20a\x20prefix\x20for\x20semantic\x20version\x0atags.\x20The\x20module\x20subdirectory\x20does\x20not\x20include\x20the\x0amajor\x20version\x20suffix,\x20if\x20there\x20is\x20one,\x20even\x20if\x20the\x0amodule\x20is\x20in\x20a\x20major\x20version\x20subdirectory.\x0aSee\x20Module\x20paths.

\x0a

\x0apackage:\x20A\x20collection\x20of\x20source\x20files\x20in\x20the\x20same\x20directory\x20that\x20are\x0acompiled\x20together.\x20See\x20the\x20Packages\x20section\x20in\x20the\x20Go\x0aLanguage\x20Specification.

\x0a

\x0apackage\x20path:\x20The\x20path\x20that\x20uniquely\x20identifies\x20a\x20package.\x20A\x20package\x20path\x20is\x0aa\x20module\x20path\x20joined\x20with\x20a\x20subdirectory\x20within\x20the\x20module.\x0aFor\x20example\x20"golang.org/x/net/html"\x20is\x20the\x20package\x20path\x20for\x20the\x20package\x20in\x20the\x0amodule\x20"golang.org/x/net"\x20in\x20the\x20"html"\x20subdirectory.\x20Synonym\x20of\x0aimport\x20path.

\x0a

\x0apatch\x20version:\x20The\x20third\x20number\x20in\x20a\x20semantic\x20version\x20(3\x20in\x20v1.2.3).\x20In\x0aa\x20release\x20with\x20no\x20changes\x20to\x20the\x20module's\x20public\x20interface,\x20the\x20patch\x20version\x0amust\x20be\x20incremented.

\x0a

\x0apre-release\x20version:\x20A\x20version\x20with\x20a\x20dash\x20followed\x20by\x20a\x20series\x20of\x0adot-separated\x20identifiers\x20immediately\x20following\x20the\x20patch\x20version,\x20for\x20example,\x0av1.2.3-beta4.\x20Pre-release\x20versions\x20are\x20considered\x20unstable\x20and\x20are\x20not\x0aassumed\x20to\x20be\x20compatible\x20with\x20other\x20versions.\x20A\x20pre-release\x20version\x20sorts\x20before\x0athe\x20corresponding\x20release\x20version:\x20v1.2.3-pre\x20comes\x20before\x20v1.2.3.\x20See\x20also\x0arelease\x20version.

\x0a

\x0apseudo-version:\x20A\x20version\x20that\x20encodes\x20a\x20revision\x20identifier\x20(such\x20as\x20a\x20Git\x0acommit\x20hash)\x20and\x20a\x20timestamp\x20from\x20a\x20version\x20control\x20system.\x20For\x20example,\x0av0.0.0-20191109021931-daa7c04131f5.\x20Used\x20for\x20compatibility\x20with\x20non-module\x0arepositories\x20and\x20in\x20other\x20situations\x20when\x20a\x20tagged\x0aversion\x20is\x20not\x20available.

\x0a

\x0arelease\x20version:\x20A\x20version\x20without\x20a\x20pre-release\x20suffix.\x20For\x20example,\x0av1.2.3,\x20not\x20v1.2.3-pre.\x20See\x20also\x20pre-release\x0aversion.

\x0a

\x0arepository\x20root\x20path:\x20The\x20portion\x20of\x20a\x20module\x20path\x20that\x0acorresponds\x20to\x20a\x20version\x20control\x20repository's\x20root\x20directory.\x20See\x20Module\x0apaths.

\x0a

\x0asemantic\x20version\x20tag:\x20A\x20tag\x20in\x20a\x20version\x20control\x20repository\x20that\x20maps\x20a\x0aversion\x20to\x20a\x20specific\x20revision.\x20See\x20Mapping\x20versions\x20to\x0acommits.

\x0a

\x0avendor\x20directory:\x20A\x20directory\x20named\x20vendor\x20that\x20contains\x20packages\x20from\x0aother\x20modules\x20needed\x20to\x20build\x20packages\x20in\x20the\x20main\x20module.\x20Maintained\x20with\x0ago\x20mod\x20vendor.\x20See\x20Vendoring.

\x0a

\x0aversion:\x20An\x20identifier\x20for\x20an\x20immutable\x20snapshot\x20of\x20a\x20module,\x20written\x20as\x20the\x0aletter\x20v\x20followed\x20by\x20a\x20semantic\x20version.\x20See\x20the\x20section\x20on\x0aVersions.

\x0a", }