//
// 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
)
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.
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,
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", "")
--- /dev/null
+# 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