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: "-: cannot find package "nonexist" in any of: ..." #38444
Comments
cc @stamblerre Errors are associated with positions in a file, and if there's no position, the error is printed with a The error's already associated with a package, so the error doesn't print its own package to avoid redundancy. |
Can we make "go build" follow the same convention then? I.e., make it print "-:" instead of "package nonexist:"? |
I don't know if that's the right thing to do here: the closer analogue to what go packages does is
|
Looks like cmd/go's "package nonexist:" output comes from: go/src/cmd/go/internal/load/pkg.go Line 396 in a55645f
|
I don't think That said,
If someone wants to fix the GOPATH-mode error message to match the module-mode one, that seems like it would be an improvement, but unless we see something similar in module mode I don't think it's worth spending much time on. |
On the go/packages side, one thing we can do is just drop the "-:" on the error's String method. That might be nicer for users if the package? |
When I run
go build nonexist
, I get:But using go/packages.Load and go/packages.PrintErrors (full code below), I get:
Is there some parser code that thinks "package nonexist:" is not a valid source position, so it gets mapped to "-:"?
Demo code:
/cc @matloob @heschik
The text was updated successfully, but these errors were encountered: