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

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

Open
baoshanxiong opened this issue Apr 2, 2024 · 3 comments
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@baoshanxiong
Copy link

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.

@gopherbot gopherbot added this to the Untriaged milestone Apr 2, 2024
@hyangah
Copy link
Contributor

hyangah commented Apr 2, 2024

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

  • Did you already import both packages from this file or other files in the same package?
  • Are they in the same module? (xxx-http-go ?)
  • Is the module (xxx-http-go) the main module this go file is in?
  • If not, how are your workspace and those modules laid out? (go.mod location and directory, file trees)
  • Can you collect gopls trace following the instruction https://github.com/golang/vscode-go/wiki/troubleshooting#collect-gopls-information and share with us? Feel free to redact confidential info?

Thanks

@hyangah hyangah changed the title Why do I use vscode to write golang code? Some packages clearly exist, but the auto-complete function does not prompt for existing packages autocomplete suggestion does not list all matching packages even when they exist Apr 2, 2024
@hyangah hyangah added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Apr 2, 2024
@baoshanxiong
Copy link
Author

版本: 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
Copy link

porterctrlz commented May 24, 2024

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: golang/go#36077

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

4 participants