mirror of
https://github.com/golang/go
synced 2024-11-11 21:20:21 -07:00
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 <bcmills@google.com> Reviewed-by: Tyler Bui-Palsulich <tbp@google.com>
This commit is contained in:
parent
c7c525a79d
commit
ff091b5fa0
@ -619,13 +619,33 @@ updating requirements in `go.mod`.
|
|||||||
## Compatibility with non-module repositories
|
## Compatibility with non-module repositories
|
||||||
|
|
||||||
<a id="mod-commands"></a>
|
<a id="mod-commands"></a>
|
||||||
## Module-aware build commands
|
## Module-aware commands
|
||||||
|
|
||||||
<a id="enabling"></a>
|
Most `go` commands may run in *Module-aware mode* or *`GOPATH` mode*. In
|
||||||
### Enabling modules
|
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.
|
||||||
|
|
||||||
<a id="initializing"></a>
|
Module-aware mode is active by default whenever a `go.mod` file is found in the
|
||||||
### Initializing modules
|
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).
|
||||||
|
|
||||||
<a id="build-commands"></a>
|
<a id="build-commands"></a>
|
||||||
### Build commands
|
### Build commands
|
||||||
@ -636,18 +656,30 @@ updating requirements in `go.mod`.
|
|||||||
<a id="go-get"></a>
|
<a id="go-get"></a>
|
||||||
### `go get`
|
### `go get`
|
||||||
|
|
||||||
|
<a id="go-list-m"></a>
|
||||||
|
### `go list -m`
|
||||||
|
|
||||||
<a id="go-mod-download"></a>
|
<a id="go-mod-download"></a>
|
||||||
### `go mod download`
|
### `go mod download`
|
||||||
|
|
||||||
<a id="go-mod-verify"></a>
|
|
||||||
### `go mod verify`
|
|
||||||
|
|
||||||
<a id="go-mod-edit"></a>
|
<a id="go-mod-edit"></a>
|
||||||
### `go mod edit`
|
### `go mod edit`
|
||||||
|
|
||||||
|
<a id="go-mod-init"></a>
|
||||||
|
### `go mod init`
|
||||||
|
|
||||||
|
<a id="go-mod-tidy"></a>
|
||||||
|
### `go mod tidy`
|
||||||
|
|
||||||
|
<a id="go-mod-verify"></a>
|
||||||
|
### `go mod verify`
|
||||||
|
|
||||||
<a id="go-clean-modcache"></a>
|
<a id="go-clean-modcache"></a>
|
||||||
### `go clean -modcache`
|
### `go clean -modcache`
|
||||||
|
|
||||||
|
<a id="module-queries"></a>
|
||||||
|
### Module queries
|
||||||
|
|
||||||
<a id="commands-outside"></a>
|
<a id="commands-outside"></a>
|
||||||
### Module commands outside a module
|
### Module commands outside a module
|
||||||
|
|
||||||
@ -828,6 +860,9 @@ setting `GOPROXY` to `https://example.com/proxy`.
|
|||||||
<a id="private-modules"></a>
|
<a id="private-modules"></a>
|
||||||
### Private modules
|
### Private modules
|
||||||
|
|
||||||
|
<a id="module-cache"></a>
|
||||||
|
### Module cache
|
||||||
|
|
||||||
<a id="authenticating"></a>
|
<a id="authenticating"></a>
|
||||||
## Authenticating modules
|
## 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
|
**module:** A collection of packages that are released, versioned, and
|
||||||
distributed together.
|
distributed together.
|
||||||
|
|
||||||
|
<a id="glos-module-cache"></a>
|
||||||
|
**module cache:** A local directory storing downloaded modules, located in
|
||||||
|
`GOPATH/pkg/mod`. See [Module cache](#module-cache).
|
||||||
|
|
||||||
<a id="glos-module-graph"></a>
|
<a id="glos-module-graph"></a>
|
||||||
**module graph:** The directed graph of module requirements, rooted at the [main
|
**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
|
module](#glos-main-module). Each vertex in the graph is a module; each edge is a
|
||||||
|
Loading…
Reference in New Issue
Block a user