Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: list: errors in build caused by -export are printed to stderr, despite -e #26319

Closed
alandonovan opened this issue Jul 10, 2018 · 1 comment

Comments

@alandonovan
Copy link
Contributor

$ cat src/a/a.go
package a

const Two = 1 + "one"
$ export GOPATH=$(pwd)
$ go list -e a 2>/dev/null
a
$ go list -e a >/dev/null
# no errors
$ go list -e -export a 2>/dev/null
a
$ go list -e -export a >/dev/null
# a
src/a/a.go:3:15: cannot convert "one" (type untyped string) to type int
src/a/a.go:3:15: invalid operation: 1 + "one" (mismatched types int and string)
$ go help list | grep -A5 ' -e '
The -e flag changes the handling of erroneous packages, those that
cannot be found or are malformed. By default, the list command
prints an error to standard error for each erroneous package and
omits the packages from consideration during the usual printing.
With the -e flag, the list command never prints errors to standard
error and instead processes the erroneous packages with the usual
printing. Erroneous packages will have a non-empty ImportPath and
a non-nil Error field; other information may or may not be missing
(zeroed).

The documentation for the -e flag says it "never prints errors to standard error", but errors in the build caused by the -export flag are in fact reported to stderr. Perhaps "errors" here means only the specific package-not-found and package-malformed kinds mentioned earlier, not all build errors, but it would be nice if all errors for a package, including build errors, could be funneled into its Package.Errors field.

@myitcv
Copy link
Member

myitcv commented Jul 10, 2018

Duplicate of #25842?

@golang golang locked and limited conversation to collaborators Jul 10, 2019
@rsc rsc removed their assignment Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants