Skip to content

Commit

Permalink
content/static/doc: document 'go mod graph'
Browse files Browse the repository at this point in the history
For golang/go#33637

Change-Id: Idb7006881b75394f2ffbfb6861fc8e54f19888ed
Reviewed-on: https://go-review.googlesource.com/c/website/+/284588
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
  • Loading branch information
passionSeven committed Jan 21, 2021
1 parent 2f995a4 commit 92025d7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
35 changes: 35 additions & 0 deletions content/static/doc/mod.md
Original file line number Diff line number Diff line change
Expand Up @@ -1415,6 +1415,41 @@ Tools may also use the package
[`golang.org/x/mod/modfile`](https://pkg.go.dev/golang.org/x/mod/modfile?tab=doc)
to parse, edit, and format `go.mod` files.

### `go mod graph` {#go-mod-graph}

Usage:

```
go mod graph
```

The `go mod graph` command prints the [module requirement
graph](#glos-module-graph) (with replacements applied) in text form. For
example:

```
example.com/main example.com/a@v1.1.0
example.com/main example.com/b@v1.2.0
example.com/a@v1.1.0 example.com/b@v1.1.1
example.com/a@v1.1.0 example.com/c@v1.3.0
example.com/b@v1.1.0 example.com/c@v1.1.0
example.com/b@v1.2.0 example.com/c@v1.2.0
```

Each vertex in the module graph represents a specific version of a module.
Each edge in the graph represents a requirement on a minimum version of a
dependency.

`go mod graph` prints the edges of the graph, one per line. Each line has two
space-separated fields: a module version and one of its dependencies. Each
module version is identified as a string of the form `path@version`. The main
module has no `@version` suffix, since it has no version.

See [Minimal version selection (MVS)](#minimal-version-selection) for more
information on how versions are chosen. See also [`go list -m`](#go-list-m) for
printing selected versions and [`go mod why`](#go-mod-why) for understanding
why a module is needed.

### `go mod init` {#go-mod-init}

Usage:
Expand Down
Loading

0 comments on commit 92025d7

Please sign in to comment.