]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: display correct options in "go help get" using modules
authorEric Ponce <tricokun@gmail.com>
Thu, 30 Aug 2018 00:27:35 +0000 (02:27 +0200)
committerBryan C. Mills <bcmills@google.com>
Mon, 17 Sep 2018 20:50:07 +0000 (20:50 +0000)
Fixes: #27298
Change-Id: Icfc6992b470136bb25a77912f670a25883642316
Reviewed-on: https://go-review.googlesource.com/132095
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/go/main.go
src/cmd/go/testdata/script/help.txt
src/cmd/go/testdata/script/mod_help.txt [new file with mode: 0644]

index 31c554e715530de632107abf78388c7ed35ec403..d6934ce5e9096a116cdc5c98eff86779feb183d8 100644 (file)
@@ -93,6 +93,15 @@ func main() {
                *get.CmdGet = *modget.CmdGet
        }
 
+       if args[0] == "get" || args[0] == "help" {
+               // Replace get with module-aware get if appropriate.
+               // Note that if MustUseModules is true, this happened already above,
+               // but no harm in doing it again.
+               if modload.Init(); modload.Enabled() {
+                       *get.CmdGet = *modget.CmdGet
+               }
+       }
+
        cfg.CmdName = args[0] // for error messages
        if args[0] == "help" {
                help.Help(os.Stdout, args[1:])
@@ -161,15 +170,6 @@ func main() {
                os.Exit(2)
        }
 
-       if args[0] == "get" {
-               // Replace get with module-aware get if appropriate.
-               // Note that if MustUseModules is true, this happened already above,
-               // but no harm in doing it again.
-               if modload.Init(); modload.Enabled() {
-                       *get.CmdGet = *modget.CmdGet
-               }
-       }
-
        // Set environment (GOOS, GOARCH, etc) explicitly.
        // In theory all the commands we invoke should have
        // the same default computation of these as we do,
index 939da30283ad2ba31351b24fbd1d6c09ab49ca9d..656e68010090d426a1d5f99052fabdecbb1cab05 100644 (file)
@@ -34,3 +34,8 @@ stderr 'Run ''go help mod'' for usage.'
 ! go vet -h
 stderr 'usage: go vet'
 stderr 'Run ''go help vet'' for details'
+
+# go help get shows usage for get
+go help get
+stdout 'usage: go get'
+stdout 'get when using GOPATH'
\ No newline at end of file
diff --git a/src/cmd/go/testdata/script/mod_help.txt b/src/cmd/go/testdata/script/mod_help.txt
new file mode 100644 (file)
index 0000000..b5cd30c
--- /dev/null
@@ -0,0 +1,6 @@
+env GO111MODULE=on
+
+# go help get shows usage for get
+go help get
+stdout 'usage: go get'
+stdout 'get using modules to manage source'
\ No newline at end of file