From: Jay Conrod Date: Fri, 10 Jan 2020 20:52:05 +0000 (-0500) Subject: doc: fill in 'Module-aware commands' section in module documentation X-Git-Tag: go1.14~9^2~21 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ff091b5fa0;p=gostls13.git doc: fill in 'Module-aware commands' section in module documentation Updates #33637 Change-Id: I6332fcdbd4c35a11cd84504f28ee594f1831ccaa Reviewed-on: https://go-review.googlesource.com/c/go/+/214378 Reviewed-by: Bryan C. Mills Reviewed-by: Tyler Bui-Palsulich --- diff --git a/doc/modules.md b/doc/modules.md index 9a0dfc7c1b..52ceb87ca8 100644 --- a/doc/modules.md +++ b/doc/modules.md @@ -619,13 +619,33 @@ updating requirements in `go.mod`. ## Compatibility with non-module repositories -## Module-aware build commands - - -### Enabling modules - - -### Initializing modules +## Module-aware commands + +Most `go` commands may run in *Module-aware mode* or *`GOPATH` mode*. In +module-aware mode, the `go` command uses `go.mod` files to find versioned +dependencies, and it typically loads packages out of the [module +cache](#glos-module-cache), downloading modules if they are missing. In `GOPATH` +mode, the `go` command ignores modules; it looks in `vendor` directories and in +`GOPATH` to find dependencies. + +Module-aware mode is active by default whenever a `go.mod` file is found in the +current directory or in any parent directory. For more fine-grained control, the +`GO111MODULE` environment variable may be set to one of three values: `on`, +`off`, or `auto`. + +* If `GO111MODULE=off`, the `go` command ignores `go.mod` files and runs in + `GOPATH` mode. +* If `GO111MODULE=on`, the `go` command runs in module-aware mode, even when + no `go.mod` file is present. Not all commands work without a `go.mod` file: + see [Module commands outside a module](#commands-outside). +* If `GO111MODULE=auto` or is unset, the `go` command runs in module-aware + mode if a `go.mod` file is present in the current directory or any parent + directory (the default behavior). + +In module-aware mode, `GOPATH` no longer defines the meaning of imports during a +build, but it still stores downloaded dependencies (in `GOPATH/pkg/mod`; see +[Module cache](#module-cache)) and installed commands (in `GOPATH/bin`, unless +`GOBIN` is set). ### Build commands @@ -636,18 +656,30 @@ updating requirements in `go.mod`. ### `go get` + +### `go list -m` + ### `go mod download` - -### `go mod verify` - ### `go mod edit` + +### `go mod init` + + +### `go mod tidy` + + +### `go mod verify` + ### `go clean -modcache` + +### Module queries + ### Module commands outside a module @@ -828,6 +860,9 @@ setting `GOPROXY` to `https://example.com/proxy`. ### Private modules + +### Module cache + ## Authenticating modules @@ -1057,6 +1092,10 @@ be incremented, and the patch version must be set to 0. **module:** A collection of packages that are released, versioned, and distributed together. + +**module cache:** A local directory storing downloaded modules, located in +`GOPATH/pkg/mod`. See [Module cache](#module-cache). + **module graph:** The directed graph of module requirements, rooted at the [main module](#glos-main-module). Each vertex in the graph is a module; each edge is a