-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Open
Labels
GoCommandcmd/gocmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Description
$ go version
go version devel go1.20-5f566d35bf Sat Oct 1 08:32:46 2022 +0000 linux/amd64
In general, go command -h
is very short at just a few lines, pointing instead to go help command
for the longer help text. However, go doc -h
is an outlier.
$ for cmd in bug build clean doc env fix fmt generate get install list mod work run test tool version vet; do echo "\$ go $cmd -h"; go $cmd -h; ech
o; done
$ go bug -h
usage: go bug
Run 'go help bug' for details.
$ go build -h
usage: go build [-o output] [build flags] [packages]
Run 'go help build' for details.
$ go clean -h
usage: go clean [clean flags] [build flags] [packages]
Run 'go help clean' for details.
$ go doc -h
Usage of [go] doc:
go doc
go doc <pkg>
go doc <sym>[.<methodOrField>]
go doc [<pkg>.]<sym>[.<methodOrField>]
go doc [<pkg>.][<sym>.]<methodOrField>
go doc <pkg> <sym>[.<methodOrField>]
For more information run
go help doc
Flags:
-all
show all documentation for package
-c symbol matching honors case (paths not affected)
-cmd
show symbols with package docs even if package is a command
-short
one-line representation for each symbol
-src
show source code for symbol
-u show unexported symbols as well as exported
exit status 2
$ go env -h
usage: go env [-json] [-u] [-w] [var ...]
Run 'go help env' for details.
$ go fix -h
usage: go fix [-fix list] [packages]
Run 'go help fix' for details.
$ go fmt -h
usage: go fmt [-n] [-x] [packages]
Run 'go help fmt' for details.
$ go generate -h
usage: go generate [-run regexp] [-n] [-v] [-x] [build flags] [file.go... | packages]
Run 'go help generate' for details.
$ go get -h
usage: go get [-t] [-u] [-v] [build flags] [packages]
Run 'go help get' for details.
$ go install -h
usage: go install [build flags] [packages]
Run 'go help install' for details.
$ go list -h
usage: go list [-f format] [-json] [-m] [list flags] [build flags] [packages]
Run 'go help list' for details.
$ go mod -h
go mod -h: unknown command
Run 'go help mod' for usage.
$ go work -h
go work -h: unknown command
Run 'go help work' for usage.
$ go run -h
usage: go run [build flags] [-exec xprog] package [arguments...]
Run 'go help run' for details.
$ go test -h
usage: go test [build/test flags] [packages] [build/test flags & test binary flags]
Run 'go help test' and 'go help testflag' for details.
$ go tool -h
usage: go tool [-n] command [args...]
Run 'go help tool' for details.
$ go version -h
usage: go version [-m] [-v] [file ...]
Run 'go help version' for details.
$ go vet -h
usage: go vet [-n] [-x] [-vettool prog] [build flags] [vet flags] [packages]
Run 'go help vet' for details.
Run 'go tool vet help' for a full list of flags and analyzers.
Run 'go tool vet -help' for an overview.
Note that go doc -h
prints many more lines than the others, but also, it prints an exit status 2
line which seems wrong. The latter seems to be because it combines CustomFlags: true
with executing go tool doc -h
, which means that the flag parsing happens in the child process, and the parent process simply shows the non-zero exit status.
We probably should:
- change
go doc -h
to show a few lines like the others, for consistency - change
go doc
to never showexit status 2
for flag errors likego doc -h
orgo doc -badflag
Also note that go tool doc -h
is slightly confusing; unlike others such as go tool fix -h
, it shows the help for go doc
rather than go tool doc
.
Metadata
Metadata
Assignees
Labels
GoCommandcmd/gocmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.