1
0
mirror of https://github.com/golang/go synced 2024-11-12 09:50:21 -07:00

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

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>
This commit is contained in:
Eric Ponce 2018-08-30 02:27:35 +02:00 committed by Bryan C. Mills
parent a19a83c8ef
commit bc529edc7f
3 changed files with 20 additions and 9 deletions

View 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,

View 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'

View File

@ -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'