1
0
mirror of https://github.com/golang/go synced 2024-11-26 21:01:31 -07:00

cmd/go: missing name in failed command error

Fixed the error reporting for an unknown command to
preserve the name when displaying the error message.

Fixes #61604

Change-Id: I13defb84e61265ab48ab514e9d4f1626a4a3f758
GitHub-Last-Rev: 5d2889c60c
GitHub-Pull-Request: golang/go#61607
Reviewed-on: https://go-review.googlesource.com/c/go/+/513555
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
This commit is contained in:
Mauri de Souza Meneguzzo 2023-08-02 13:47:16 +00:00 committed by Gopher Robot
parent 2350afd2e8
commit 76b8e80fab
2 changed files with 7 additions and 1 deletions

View File

@ -175,7 +175,11 @@ func main() {
if used > 0 {
helpArg += " " + strings.Join(args[:used], " ")
}
fmt.Fprintf(os.Stderr, "go %s: unknown command\nRun 'go help%s' for usage.\n", cfg.CmdName, helpArg)
cmdName := cfg.CmdName
if cmdName == "" {
cmdName = args[0]
}
fmt.Fprintf(os.Stderr, "go %s: unknown command\nRun 'go help%s' for usage.\n", cmdName, helpArg)
base.SetExitStatus(2)
base.Exit()
}

View File

@ -0,0 +1,2 @@
! go asdf
stderr '^go asdf: unknown command'