-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: "unsafe" should contain GoFiles=["unsafe/unsafe.go"] #59929
Comments
Change https://go.dev/cl/491375 mentions this issue: |
On the
But perhaps we should be reporting |
I'm not sure either. IgnoredGoFiles says it's for "files that might be part of the package using other build configurations" and are thus valid syntax, whereas GoFiles (as a matter of fact---it's not documented) holds the cgo source files, which are not really valid Go syntax. So I think GoFiles may be a better fit. |
(For example, the files could contain |
True. But the unsafe.go and builtin.go source files are never supposed to be seen by the compiler. |
Since its inception, go/packages has discarded the GoFiles field of the
unsafe
package. (I don't remember why I implemented it this way: perhaps I thought that GoFiles was for files that contain valid Go syntax but are de-selected from the build due to non-matching build tags, whereas it's debatable whether unsafe.go is valid Go. It can't be compiled without a .s file because it has missing function bodies, for example.) In any case, the unsafe package nearly always needs special handling by client applications, and it is inconvenient for some (e.g. gopls) to know the location of the unsafe.go file, so that it can be presented as documentation, and there is insufficient information to compute it from the packages.Package record for package "unsafe", which contains only the ID, Path, and Name fields, but no file names at all.In hindsight I think it makes sense to include unsafe.go among the non-compiled GoFiles. I suspect the change is low risk because (as I mentioned) unsafe nearly always requires special handling anyway, and the GoFiles are never processed by the type checker.
The text was updated successfully, but these errors were encountered: