x/tools/go/analysis/cmd/vet: add -cgoinclude check for #include of code in subdirectories
#26,506 opened on Jul 20, 2018
Repository metrics
- Stars
- (133,883 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
The go build model is that all code for a package is in one directory. The cache relies on this. Vendoring tools rely on this. Probably many other things rely on this.
One of the few ways a package can violate this rule is by using #include in cgo source code to access code in nearby directories. This appears to work, in that the package builds, but it doesn't cache properly, doesn't vendor properly, and so on.
It seems reasonable for cmd/vet to notice such #includes and complain about them, and we could enable that check as one of the automatic ones run during go test.
Suggested in #26366.