From: ianwoolf Date: Wed, 9 Nov 2022 08:40:24 +0000 (+0800) Subject: cmd/go: enable -x in go mod tidy X-Git-Tag: go1.20rc1~314 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=86bbcc6a7503e96ea55d5c685141c7d109b07cde;p=gostls13.git cmd/go: enable -x in go mod tidy Updates #35849 Change-Id: I8b40a2de6a05880a9f939349a714b631888f5f94 Reviewed-on: https://go-review.googlesource.com/c/go/+/448915 Reviewed-by: Bryan Mills Auto-Submit: Bryan Mills TryBot-Result: Gopher Robot Reviewed-by: Michael Knyszek Run-TryBot: Bryan Mills --- diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 821ebef3ac..ceae79b524 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -1285,7 +1285,7 @@ // // Usage: // -// go mod tidy [-e] [-v] [-go=version] [-compat=version] +// go mod tidy [-e] [-v] [-x] [-go=version] [-compat=version] // // Tidy makes sure go.mod matches the source code in the module. // It adds any missing modules necessary to build the current module's @@ -1313,6 +1313,8 @@ // version prior to the one indicated by the 'go' directive in the go.mod // file. // +// The -x flag causes tidy to print the commands download executes. +// // See https://golang.org/ref/mod#go-mod-tidy for more about 'go mod tidy'. // // # Make vendored copy of dependencies diff --git a/src/cmd/go/internal/modcmd/tidy.go b/src/cmd/go/internal/modcmd/tidy.go index 27889941c7..7e33ad2ded 100644 --- a/src/cmd/go/internal/modcmd/tidy.go +++ b/src/cmd/go/internal/modcmd/tidy.go @@ -19,7 +19,7 @@ import ( ) var cmdTidy = &base.Command{ - UsageLine: "go mod tidy [-e] [-v] [-go=version] [-compat=version]", + UsageLine: "go mod tidy [-e] [-v] [-x] [-go=version] [-compat=version]", Short: "add missing and remove unused modules", Long: ` Tidy makes sure go.mod matches the source code in the module. @@ -48,6 +48,8 @@ version. By default, tidy acts as if the -compat flag were set to the version prior to the one indicated by the 'go' directive in the go.mod file. +The -x flag causes tidy to print the commands download executes. + See https://golang.org/ref/mod#go-mod-tidy for more about 'go mod tidy'. `, Run: runTidy, @@ -61,6 +63,7 @@ var ( func init() { cmdTidy.Flag.BoolVar(&cfg.BuildV, "v", false, "") + cmdTidy.Flag.BoolVar(&cfg.BuildX, "x", false, "") cmdTidy.Flag.BoolVar(&tidyE, "e", false, "") cmdTidy.Flag.Var(&tidyGo, "go", "") cmdTidy.Flag.Var(&tidyCompat, "compat", "") diff --git a/src/cmd/go/testdata/script/mod_tidy_support_buildx.txt b/src/cmd/go/testdata/script/mod_tidy_support_buildx.txt new file mode 100644 index 0000000000..d2135e1fff --- /dev/null +++ b/src/cmd/go/testdata/script/mod_tidy_support_buildx.txt @@ -0,0 +1,18 @@ +# This test checks that "go mod tidy -x" print +# commands tidy executes. +# Verifies golang.org/issue/35849 + +rm $GOPATH/pkg/mod/cache/download/rsc.io/quote +go mod tidy +! stderr 'get '$GOPROXY + +rm $GOPATH/pkg/mod/cache/download/rsc.io/quote +go mod tidy -x +stderr 'get '$GOPROXY + +-- go.mod -- +module example.com/mod + +-- a.go -- +package mod +import _ "rsc.io/quote" \ No newline at end of file