mirror of
https://github.com/golang/go
synced 2024-09-29 01:24:34 -06:00
cmd/go: enable -x in go mod graph
Updates #35849 Change-Id: Ifa18e448c0d436c18d7204ac755cd36bc28cd612 Reviewed-on: https://go-review.googlesource.com/c/go/+/448935 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
86bbcc6a75
commit
fcecf3e1fa
@ -1248,7 +1248,7 @@
|
||||
//
|
||||
// Usage:
|
||||
//
|
||||
// go mod graph [-go=version]
|
||||
// go mod graph [-go=version] [-x]
|
||||
//
|
||||
// Graph prints the module requirement graph (with replacements applied)
|
||||
// in text form. Each line in the output has two space-separated fields: a module
|
||||
@ -1259,6 +1259,8 @@
|
||||
// given Go version, instead of the version indicated by the 'go' directive
|
||||
// in the go.mod file.
|
||||
//
|
||||
// The -x flag causes graph to print the commands graph executes.
|
||||
//
|
||||
// See https://golang.org/ref/mod#go-mod-graph for more about 'go mod graph'.
|
||||
//
|
||||
// # Initialize new module in current directory
|
||||
|
@ -12,13 +12,14 @@ import (
|
||||
"os"
|
||||
|
||||
"cmd/go/internal/base"
|
||||
"cmd/go/internal/cfg"
|
||||
"cmd/go/internal/modload"
|
||||
|
||||
"golang.org/x/mod/module"
|
||||
)
|
||||
|
||||
var cmdGraph = &base.Command{
|
||||
UsageLine: "go mod graph [-go=version]",
|
||||
UsageLine: "go mod graph [-go=version] [-x]",
|
||||
Short: "print module requirement graph",
|
||||
Long: `
|
||||
Graph prints the module requirement graph (with replacements applied)
|
||||
@ -30,6 +31,8 @@ The -go flag causes graph to report the module graph as loaded by the
|
||||
given Go version, instead of the version indicated by the 'go' directive
|
||||
in the go.mod file.
|
||||
|
||||
The -x flag causes graph to print the commands graph executes.
|
||||
|
||||
See https://golang.org/ref/mod#go-mod-graph for more about 'go mod graph'.
|
||||
`,
|
||||
Run: runGraph,
|
||||
@ -41,6 +44,7 @@ var (
|
||||
|
||||
func init() {
|
||||
cmdGraph.Flag.Var(&graphGo, "go", "")
|
||||
cmdGraph.Flag.BoolVar(&cfg.BuildX, "x", false, "")
|
||||
base.AddChdirFlag(&cmdGraph.Flag)
|
||||
base.AddModCommonFlags(&cmdGraph.Flag)
|
||||
}
|
||||
|
5
src/cmd/go/testdata/script/mod_graph.txt
vendored
5
src/cmd/go/testdata/script/mod_graph.txt
vendored
@ -4,6 +4,11 @@ go mod graph
|
||||
stdout '^m rsc.io/quote@v1.5.2$'
|
||||
stdout '^rsc.io/quote@v1.5.2 rsc.io/sampler@v1.3.0$'
|
||||
! stdout '^m rsc.io/sampler@v1.3.0$'
|
||||
! stderr 'get '$GOPROXY
|
||||
|
||||
rm $GOPATH/pkg/mod/cache/download/rsc.io/quote
|
||||
go mod graph -x
|
||||
stderr 'get '$GOPROXY
|
||||
|
||||
-- go.mod --
|
||||
module m
|
||||
|
@ -57,7 +57,7 @@ stdout '^example.net/requireincompatible@v0.1.0 example.com/retract/incompatible
|
||||
# Unsupported go versions should be rejected, since we don't know
|
||||
# what versions they would report.
|
||||
! go mod graph -go=1.99999999999
|
||||
stderr '^invalid value "1\.99999999999" for flag -go: maximum supported Go version is '$goversion'\nusage: go mod graph \[-go=version\]\nRun ''go help mod graph'' for details.$'
|
||||
stderr '^invalid value "1\.99999999999" for flag -go: maximum supported Go version is '$goversion'\nusage: go mod graph \[-go=version\] \[-x\]\nRun ''go help mod graph'' for details.$'
|
||||
|
||||
|
||||
-- go.mod --
|
||||
|
Loading…
Reference in New Issue
Block a user