Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/go: go list -export -e outputs errors to stderr and has non-zero exit code #25842
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
It seems to me that
That does suggest that we should refine the documentation, though. It's not quite accurate to say that “[w]ith the -e flag, the list command never prints errors to standard error”.
To make it concrete, the issue I see with this is that as the caller of
We could use some sort of semantic that says "if there is any output on stdout then use it as an indicator of success, compile errors will be reported to stderr", but this seems somewhat brittle.
@bcmills do you see another way of me distinguishing between cases 1 and 2 above?
Which is why I felt the semantics of
In general go/packages must expect that the subcommand it runs ("go list" or any other helper like bazel) can exit unsuccessfully and print errors to standard output/error. That should make Load fail, returning an err including the output. The usual way to generate such an error is:
If errors happen during the build for -export, I agree that go list -e should ideally report them in the Package structs. But go/packages must be able to handle the current failure mode regardless, even if it's not quite right for the question that was asked.
Leaving for Go 1.12.