Skip to content
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/vgo: always provide package name alongside import path #24361

Closed
josharian opened this issue Mar 12, 2018 · 1 comment
Closed

x/vgo: always provide package name alongside import path #24361

josharian opened this issue Mar 12, 2018 · 1 comment
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@josharian
Copy link
Contributor

This is going to be vague; apologies.

One source of frustration when working programmatically with imports is the need to use expensive go/build.Import calls to go from a package's import path to its name.

If you have a qualified identifier of interest, you need to build.Import the import path of every un-named import spec in the file (which is usually most of them) to find out whether the package name matches. This can have disproportionate cost.

This problem is particularly acute when you want to go from package name to import paths, as goimports does. You would need to read the entirety of the GOPATH to find matching packages. For performance reasons, goimports currently declines to do this and uses some heuristics around naming conventions to cut down on the number of candidate import paths. That's fine for goimports, but not for (say) guru.

vgo seems likely to be the future source of truth about all imports of interest in a project. It seems to me this might provide an opportunity for go.mod to provide a canonical mapping between package import paths and names, one that can be consumed with minimal I/O and filesystem interaction.

@rsc @alandonovan @keegancsmith @bradfitz

@josharian josharian added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Mar 12, 2018
@josharian josharian added this to the vgo milestone Mar 12, 2018
@rsc
Copy link
Contributor

rsc commented Mar 26, 2018

I don't think this can be done. vgo lists modules, each of which can have many packages. We don't want to force the go.mod file to list all the packages in the modules just to give their package names.

@rsc rsc closed this as completed Mar 26, 2018
@golang golang locked and limited conversation to collaborators Mar 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

3 participants