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

x/tools/go/packages: clarify error invariants #28231

Open
alandonovan opened this Issue Oct 16, 2018 · 0 comments

Comments

Projects
None yet
4 participants
@alandonovan
Copy link
Contributor

alandonovan commented Oct 16, 2018

$ ./gopackages -mode=allsyntax "" "nonesuch"
Go package "_/home/adonovan/got/src/golang.org/x/tools": (has errors)
        has complete exported type info
        -: no Go files in /home/adonovan/got/src/golang.org/x/tools

Go package "nonesuch": (has errors)
        has complete exported type info
        -: cannot find package "nonesuch" in any of:
        /home/adonovan/goroot/src/nonesuch (from $GOROOT)
        /home/adonovan/go/src/nonesuch (from $GOPATH)

packages.Load("nonesuch") and Load("") both return a Package, presumably just as a place to hold errors. The package Name field is empty, which is a good clue that the package doesn't exist, and the Errors slice is non-empty. However, the Types field is non-nil and Complete(), which causes the gopackages diagnostic/example tool to report "has complete exported type info" for a package that doesn't exist.

The task of this issue is to clarify which fields can be relied upon in each error scenario and to improve the output and logic of the gopackages tool to reflect this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment