-
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: support for loading files/syntax irrespective of build tags #28121
Comments
One option discussed so far has been to make multiple calls to As was noted on yesterday's call, returning type information in this situation doesn't make sense. However the @matloob - perhaps you could comment on this particular question? |
If I recall our meeting correctly, what @ianthehat was suggesting is a separate package that works on directories, not buildable packages. I presume that it would look more like a mix of the old That sounds fine to me, and I presume it would require no changes to |
They're not strictly separate, unfortunately. For example, in a tool like |
Responding to @myitcv's question, it's not just the type information that doesn't make sense: adding the same file twice to a fileset will create two entries for that file, with different 'pos' values. So I don't think changing or adding a new Mode will help too much with this. I think the best we can do is to call Load in LoadFiles mode and call parsefile ourselves. Calling parsefile is one of the simpler things go/packages does. We suggested that this is something that could be done with go/packages, but I think go/packages isn't a good fit for this problem. Like @mvdan mentioned, a separate packages that works on directories might be the better solution. And because it wouldn't have to support other buildsystems, it wouldn't be hamstrung by the limitations go/packages faces. |
Related to #27900 in as much as |
This feature probably requires #42504. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, per above
What operating system and processor architecture are you using (
go env
)?Picking up on the discussion from the 2018-10-09 golang-tools catch up
In the pre-modules world,
go/build
andgo/parser
could be used in combination to get file and syntax information for packages and their dependencies irrespective ofGOOS
,GOARCH
and build tags via theUseAllFiles
go/build.Context
field.This use case is important for tools like
govers
andgogrep
.go/packages
is driven byConfig
which includesGOOS
,GOARCH
and build tags and hence its response is specific to the provided config.go/packages
cannot, therefore, be used in these use cases.This issue is a placeholder to continue discussion about how best to support loading of files, imports and syntax in a
GOOS
,GOARCH
and build tags-agnostic way.cc @ianthehat @matloob @alandonovan @bcmills @rogpeppe @mvdan
The text was updated successfully, but these errors were encountered: