x/tools/gopls: prefer modules in go.mod
when importing or ranking completion items
#38461
Labels
FrozenDueToAge
gopls
Issues related to the Go language server, gopls.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
go version: 1.14
gopls version: 0.4.0
When there are multiple matching packages with similar APIs (e.g. v1 vs v2)
and users already specified the preference in their
go.mod
, I think, choosingthe one listed in the
go.mod
makes more sense.Let's assume an incomplete go file:
When only one version exists in the module cache, everything works fine.
Let's add the version 1 in the module cache, but leave the original go.mod file untouched.
(So, only the v2 module is listed)
Same idea can apply to the auto-completion. In the below image, the completion item lists include candidates from both v1 and v2. The VS Code UI is not great at telling where the candidate is from. The first
APICall
is from v1.The text was updated successfully, but these errors were encountered: