diff options
| author | Ian Alexander <jitsu@google.com> | 2025-05-30 17:59:34 -0400 |
|---|---|---|
| committer | Ian Alexander <jitsu@google.com> | 2025-07-21 08:29:11 -0700 |
| commit | e5502e0959bb54ec70ca500e8d2b6f5ac5efbc53 (patch) | |
| tree | ef555030ad8067a6c3cd577cc1e190437750dfc5 | |
| parent | 2363897932cfb279dd8810d2c92438f7ddcfd951 (diff) | |
| download | go-e5502e0959bb54ec70ca500e8d2b6f5ac5efbc53.tar.xz | |
cmd/go: check subcommand properties
This change corrects the properties checked by Lookup. We were
inspecting the properties of the Command receiver; now we are
inspecting the properties of the subcommand.
Fixes #73864.
Change-Id: Ieb462e489fc4f8f0568aa3a2d404b322d627166c
Reviewed-on: https://go-review.googlesource.com/c/go/+/678655
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
| -rw-r--r-- | src/cmd/go/internal/base/base.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/cmd/go/internal/base/base.go b/src/cmd/go/internal/base/base.go index 83cbad401e..d5d5f8d36e 100644 --- a/src/cmd/go/internal/base/base.go +++ b/src/cmd/go/internal/base/base.go @@ -62,11 +62,11 @@ var Go = &Command{ // Lookup returns the subcommand with the given name, if any. // Otherwise it returns nil. // -// Lookup ignores subcommands that have len(c.Commands) == 0 and c.Run == nil. +// Lookup ignores any subcommand `sub` that has len(sub.Commands) == 0 and sub.Run == nil. // Such subcommands are only for use as arguments to "help". func (c *Command) Lookup(name string) *Command { for _, sub := range c.Commands { - if sub.Name() == name && (len(c.Commands) > 0 || c.Runnable()) { + if sub.Name() == name && (len(sub.Commands) > 0 || sub.Runnable()) { return sub } } |
