Commit bc529edc authored by Eric Ponce's avatar Eric Ponce Committed by Bryan C. Mills

cmd/go: display correct options in "go help get" using modules

Fixes: #27298

Change-Id: Icfc6992b470136bb25a77912f670a25883642316
Reviewed-on: https://go-review.googlesource.com/132095Reviewed-by: 's avatarBryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent a19a83c8
......@@ -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,
......
......@@ -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
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment