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/tools/gopls: inaccurate functionality for import with package name mismatching its path #51411

Closed
findleyr opened this issue Mar 1, 2022 · 8 comments
Labels
FrozenDueToAge gopls/completion Issues related to auto-completion in gopls. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@findleyr
Copy link
Contributor

findleyr commented Mar 1, 2022

Reported in slack: gopls offers inaccurate functionality when importing github.com/wagslane/go-rabbitmq, which has the package name "rabbitmq". Completion is inaccurate, and import statements get removed on save:

image

@hyangah points out that this only happens when the module is not yet required by the go.mod. This is therefore probably a chicken-and-egg problem, but one that can be quite confusing for our users.

@findleyr findleyr added this to the gopls/on-deck milestone Mar 1, 2022
@hyangah
Copy link
Contributor

hyangah commented Mar 1, 2022

@hyangah points out that this only happens when the module is not yet required by the go.mod. This is therefore probably a chicken-and-egg problem, but one that can be quite confusing for our users.

I was late in reading the slack - more confusion: the user reported that the user's code builds and there is no vet error. If the module wasn't required in the go.mod file, build and vet couldn't be successful. So, I am not sure if the user is seeing the same problem I observed. 🤔

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Mar 1, 2022
@KoduIsGreat
Copy link

KoduIsGreat commented Mar 1, 2022

@hyangah, @findleyr Hi, I'm the user that reported this issue in slack.
to clarify, the package is required in the go.mod.

To me it seems like gopls is using the ending segment of the import path rather than the declared package identifier.

@findleyr findleyr changed the title x/tools/gopls: inaccurate functionality for mismatching package name in unrequired module x/tools/gopls: inaccurate functionality for import with package name mismatching its path Mar 1, 2022
@findleyr
Copy link
Contributor Author

findleyr commented Mar 1, 2022

@KoduIsGreat thank you for clarifying. I've updated the issue accordingly.

@muirdm
Copy link

muirdm commented Apr 24, 2022

I couldn't reproduce this. I tried various things but only ever saw completions for "rabbitmq" (never "go-rabbitmq"), which added the proper import and overall worked as expected. Are you certain that completion was coming from gopls?

AFAIK the unimported package completions first look at other imports in your workspace taking in to account declared package name, otherwise falling back to searching GOMODCACHE which also takes in to account declared package name by parsing a single file in each directory.

@KoduIsGreat
Copy link

If the completion wasn't coming from gopls, what else would it be coming from.

@muirdm
Copy link

muirdm commented Apr 25, 2022

I dunno, some other VS Code integrated tool. Anyway, can you give steps to reproduce?

@suzmue suzmue added the gopls/completion Issues related to auto-completion in gopls. label May 10, 2022
@findleyr findleyr added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label May 18, 2022
@hyangah
Copy link
Contributor

hyangah commented May 24, 2022

@gopherbot
Copy link

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@findleyr findleyr closed this as not planned Won't fix, can't repro, duplicate, stale Jul 1, 2022
@golang golang locked and limited conversation to collaborators Jul 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls/completion Issues related to auto-completion in gopls. gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

6 participants