You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I expected these commands to write to stdout. I was trying to see what the -i flag in go build -i does, so I ran the command go build --help | grep -- -i.
What did you see instead?
My buffer was flooded with the entire go build --help message because it writes to stderr instead of stdout. This means I have to run go {subcommand} --help 2>&1 | grep -- -{flag} when figuring out what a flag does.
However, when running commands like go env and go version, output is written to stdout. This leads to confusion: when should I have to combine stderr and stdout? What if there was a genuine error in the go {subcommand} that I run? I don't want to pipe that through grep and miss it, it may be important.
I think go should pick a file descriptor---either stdout or stderr---to write all go output to. In my opinion, go should only ever write to stderr if the binary itself fails in some respect. That way I don't miss any errors because I'm piping all of stderr through grep, head, and the like.
The text was updated successfully, but these errors were encountered:
It is intended. Conceptually, what you're seeing in response to "go build --help" is an error message. This is also signaled by the program exiting with a status of 2. Go build does not accept a "--help" flag and thus exits, printing usage information for your convenience.
If you want to access its help, use "go help" as the message is telling you. This is not a bug.
Version
go 1.7 darwin/amd64
OS + Architecture
What did I do?
go --help
andgo [subcommand] --help
What did you expect to see?
I expected these commands to write to stdout. I was trying to see what the
-i
flag ingo build -i
does, so I ran the commandgo build --help | grep -- -i
.What did you see instead?
My buffer was flooded with the entire
go build --help
message because it writes tostderr
instead ofstdout
. This means I have to rungo {subcommand} --help 2>&1 | grep -- -{flag}
when figuring out what a flag does.However, when running commands like
go env
andgo version
, output is written tostdout
. This leads to confusion: when should I have to combinestderr
andstdout
? What if there was a genuine error in thego {subcommand}
that I run? I don't want to pipe that through grep and miss it, it may be important.I think
go
should pick a file descriptor---eitherstdout
orstderr
---to write allgo
output to. In my opinion,go
should only ever write tostderr
if the binary itself fails in some respect. That way I don't miss any errors because I'm piping all ofstderr
throughgrep
,head
, and the like.The text was updated successfully, but these errors were encountered: