diff --git a/src/cmd/go/internal/base/base.go b/src/cmd/go/internal/base/base.go index e7f54c9a365fef..345bf4c0771a8f 100644 --- a/src/cmd/go/internal/base/base.go +++ b/src/cmd/go/internal/base/base.go @@ -30,7 +30,7 @@ type Command struct { Run func(cmd *Command, args []string) // UsageLine is the one-line usage message. - // The first word in the line is taken to be the command name. + // The words between "go" and the first flag or argument in the line are taken to be the command name. UsageLine string // Short is the short description shown in the 'go help' output. diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go index 8dfb3df22d3b9e..fe90af3be51f51 100644 --- a/src/cmd/go/internal/test/test.go +++ b/src/cmd/go/internal/test/test.go @@ -514,10 +514,16 @@ var testVetFlags = []string{ // "-unusedresult", } +func testCmdUsage() { + fmt.Fprintf(os.Stderr, "usage: %s\n", CmdTest.UsageLine) + fmt.Fprintf(os.Stderr, "Run 'go help %s' and 'go help %s' for details.\n", CmdTest.LongName(), HelpTestflag.LongName()) + os.Exit(2) +} + func runTest(cmd *base.Command, args []string) { modload.LoadTests = true - pkgArgs, testArgs = testFlags(cmd.Usage, args) + pkgArgs, testArgs = testFlags(testCmdUsage, args) work.FindExecCmd() // initialize cached result diff --git a/src/cmd/go/testdata/script/help.txt b/src/cmd/go/testdata/script/help.txt index e6cbc829281cbd..9752ede2e37283 100644 --- a/src/cmd/go/testdata/script/help.txt +++ b/src/cmd/go/testdata/script/help.txt @@ -42,7 +42,7 @@ stderr 'Run ''go tool vet -help'' for the vet tool''s flags' # lines. ! go test -h stderr 'usage: go test' -stderr 'Run ''go help test'' for details' +stderr 'Run ''go help test'' and ''go help testflag'' for details.' # go help get shows usage for get go help get