go: use module sources digest for each of its packages #17728
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
As reported in #17592, third-party Go modules are allowed to assume that all files packaged with the module will be visible during compilation. In that particular issue, the Confluent Kafka client library uses Cgo and expected a subdirectory with files used during C compilation will be visible to the package using Cgo.
Pants, however, subsets the modules sources digest to just the files in the exact subdirectory for each of the module's packages. This means that the subdirectory files were not visible when compiling the package in confluent-kafka-go in the immediate parent directory.
Solution
Since Pants cannot predict how a third party package will use the files in the modules sources, Pants cannot reasonably subset the modules source digest. Solve the issue by not subsetting the module sources digest to produce a package-specific digest.
This is a partial fix for #17592.