golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.78k stars 728 forks source link

autocomplete suggestion does not list all matching packages even when they exist #3300

Open baoshanxiong opened 3 months ago

baoshanxiong commented 3 months ago

go version: 1.20

Steps to Reproduce:

image

There is a service/gift package and a store/gift package, but vscode automatically prompts only the service/gift package.

hyangah commented 3 months ago

@baoshanxiong thanks for the report. We need more info for investigation.

Thanks

baoshanxiong commented 2 months ago

版本: 1.88.1 提交: e170252f762678dec6ca2cc69aba1570769a5d39 日期: 2024-04-10T17:43:08.196Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Darwin arm64 23.4.0

porterctrlz commented 1 month ago

At the very least, if you've yet to import a package that shares a name with other packages, vscode-go will correctly suggest all versions:

Screenshot 2024-05-23 at 4 55 00 PM

But once you've imported one of those packages, the suggestion will only show exports from that package:

Screenshot 2024-05-23 at 4 55 20 PM

This makes the autocomplete story very brittle when you happen to have a package name clash, something that would be great to auto-alias if you navigate through and select suggested packages.

This seems related: https://github.com/golang/go/issues/36077

Toy repo here: https://github.com/controlzee/gopls-package-shadow