]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: enable -x in go mod tidy
authorianwoolf <btw515wolf2@gmail.com>
Wed, 9 Nov 2022 08:40:24 +0000 (16:40 +0800)
committerGopher Robot <gobot@golang.org>
Thu, 10 Nov 2022 21:10:40 +0000 (21:10 +0000)
Updates #35849

Change-Id: I8b40a2de6a05880a9f939349a714b631888f5f94
Reviewed-on: https://go-review.googlesource.com/c/go/+/448915
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>

src/cmd/go/alldocs.go
src/cmd/go/internal/modcmd/tidy.go
src/cmd/go/testdata/script/mod_tidy_support_buildx.txt [new file with mode: 0644]

index 821ebef3ac987bc8a1e498426ed2e6c4efc882d9..ceae79b5245ec50a08da972856e4f999e862a286 100644 (file)
 //
 // 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
 // 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
index 27889941c72ef939f0db6e38cbd08700ce2036ab..7e33ad2ded49561777d9411e8a789b58d5397978 100644 (file)
@@ -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 (file)
index 0000000..d2135e1
--- /dev/null
@@ -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