-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
Comments
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 |
@KoduIsGreat thank you for clarifying. I've updated the issue accordingly. |
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. |
If the completion wasn't coming from gopls, what else would it be coming from. |
I dunno, some other VS Code integrated tool. Anyway, can you give steps to reproduce? |
gopls trace may be helpful to verify https://github.com/golang/vscode-go/wiki/troubleshooting#collect-gopls-information |
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.) |
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:
@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.The text was updated successfully, but these errors were encountered: