-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Description
What version of Go are you using (go version
)?
go version go1.11 darwin/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env
)?
$ go env
GOARCH="amd64"
GOBIN="/Users/fatih/go/bin"
GOCACHE="/Users/fatih/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/fatih/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/k_/87syx3r50m93m72hvqj2qqlw0000gn/T/go-build154500786=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
I asked to print the help usage of the command go list
:
$ go list --help
usage: go list [-f format] [-json] [-m] [list flags] [build flags] [packages]
Run 'go help list' for details.
What did you expect to see?
I would like to see the help output instead of suggesting me to run go help list
.
# example output I would like to see:
$ go list --help
usage: go list [-f format] [-json] [-m] [list flags] [build flags] [packages]
List lists the named packages, one per line.
The most commonly-used flags are -f and -json, which control the form
of the output printed for each package. Other list flags, documented below,
control more specific details.
...
What did you see instead?
It suggested to me to run go help list
.
I think this is a not very user friendly output. --help
(or -h
) is a very common flag and is even parsed by the flag
package. The go
command understand that I'm seeking for a help, instead of suggesting me to run go help list
, it should show me the help message.
As an example user case, suppose you run a command and somehow wrote it wrong:
$ go list -f
flag needs an argument: -f
usage: go list [-f format] [-json] [-m] [list flags] [build flags] [packages]
Run 'go help list' for details.
If the go
command would support the --help
/-h
flags, I could press the up
key on my keyboard (the shell would show the last executed command) and append the --help
flag to see what's wrong:
$ go list -f --help
usage: go list [-f format] [-json] [-m] [list flags] [build flags] [packages]
List lists the named packages, one per line.
The most commonly-used flags are -f and -json, which control the form
of the output printed for each package. Other list flags, documented below,
control more specific details.
...
This example is not only about go list
itself, this applies to every single subcommand of the go
command. This happens so many times and I think it's counter intuitive to write a comand from scratch (i.e: go help list
, go help test
, ...). I don't know the origin why --help
or -h
is permitted and not allowed to be used, but if it's something that can be removed, I suggest we remove the restriction and show the help message instead of suggesting to call go help subcommand
(for subcommand related --help messages).