Skip to content

Commit c43232f

Browse files
committed
cmd/digraph: improve examples using go list, mod
Change-Id: Ib04b11b32f40f1602eb4cf0837e331b77511b6c5 Reviewed-on: https://go-review.googlesource.com/c/tools/+/502875 gopls-CI: kokoro <[email protected]> Run-TryBot: Alan Donovan <[email protected]> TryBot-Bypass: Alan Donovan <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 6e1595c commit c43232f

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

cmd/digraph/digraph.go

+16-7
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,27 @@ shirt -> sweater, not shirt -> tie -> sweater.
6363
6464
Example usage:
6565
66-
Using digraph with existing Go tools:
66+
Show which clothes (see above) must be donned before a jacket:
6767
68-
$ go mod graph | digraph nodes # Operate on the Go module graph.
69-
$ go list -m all | digraph nodes # Operate on the Go package graph.
68+
$ digraph reverse jacket
7069
71-
Show the transitive closure of imports of the digraph tool itself:
70+
Many tools can be persuaded to produce output in digraph format,
71+
as in the following examples.
7272
73-
$ go list -f '{{.ImportPath}} {{join .Imports " "}}' ... | digraph forward golang.org/x/tools/cmd/digraph
73+
Using an import graph produced by go list, show a path that indicates
74+
why the gopls application depends on the cmp package:
7475
75-
Show which clothes (see above) must be donned before a jacket:
76+
$ go list -f '{{.ImportPath}} {{join .Imports " "}}' -deps golang.org/x/tools/gopls |
77+
digraph somepath golang.org/x/tools/gopls github.com/google/go-cmp/cmp
7678
77-
$ digraph reverse jacket
79+
Show which packages in x/tools depend, perhaps indirectly, on the callgraph package:
80+
81+
$ go list -f '{{.ImportPath}} {{join .Imports " "}}' -deps golang.org/x/tools/... |
82+
digraph reverse golang.org/x/tools/go/callgraph
83+
84+
Using a module graph produced by go mod, show all dependencies of the current module:
85+
86+
$ go mod graph | digraph forward $(go list -m)
7887
*/
7988
package main // import "golang.org/x/tools/cmd/digraph"
8089

0 commit comments

Comments
 (0)