Open
Description
Go version
go version go1.24.3 darwin/arm64
Output of go env
in your module/workspace:
AR='ar'
CC='cc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='c++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/shagohead/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/shagohead/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/42/bbf9km4n01gcwwq1swy33tlw0000gn/T/go-build3288280414=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/Users/shagohead/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/shagohead/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.24.3/libexec'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/shagohead/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.24.3/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.3'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
Looks like Command.Lookup
have a typo and checks command itself instead of subcommands at each subcommand iteration
What did you see happen?
On each iteration of range c.Commands
condition checks name of sub
command and checks if c
is runnable or has subcommands. Looks like it should check that for sub
.
What did you expect to see?
diff --git a/src/cmd/go/internal/base/base.go b/src/cmd/go/internal/base/base.go
index 83cbad401e..6b203575a8 100644
--- a/src/cmd/go/internal/base/base.go
+++ b/src/cmd/go/internal/base/base.go
@@ -66,7 +66,7 @@ var Go = &Command{
// 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
}
}