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/gopls: doesn't report errors for disallowed uses of internal packages #35937
Comments
Hi @stamblerre - has anyone started this? Thought I could give it a whirl. |
No I don't think anyone has! Please go ahead. The code you'll want to look at is here. We'll probably need to detect if the package is an allowed internal package and then add an error. Here's the formal documentation for internal packages: https://golang.org/cmd/go/#hdr-Internal_Directories. |
Sound good! Thanks for the pointers. One question - is it safe to rely on the pkgPath from the metadata passed in to |
|
Great - I created a PR here. While looking through the code, I found an alternative way to perform the check (using the analysis API) which seems to have the benefit of working with the |
Anything in the The analysis API is typically for analyses on top of type-checked code, but in the case of a package with an invalid import, it really shouldn't even type check. We could potentially add a diagnostic instead of failing to type-check, but that would have the misleading effect of showing users completions that won't compile. |
Fixed via CL 218977. |
Forked from microsoft/vscode-go#2926.
Repro:
Add the following to
golang.org/x/tools/blog/blog.go
:This code will not compile, but we don't report any errors for it.
The text was updated successfully, but these errors were encountered: