-
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: gopls completes a function from an unimported module in the vendor path but uses an incorrect import path with "vendor/" #71474
Comments
@xckomorebi, the issue is not reproducible. Are you working on an open source repo on which we can check? |
Please check this commit |
@xckomorebi I see you are using GO111MODULE='off' (i.e. GOPATH mode). That is almost certainly related. GOPATH mode does not have good support, and is unlikely to get fixes. I suggest using Go modules. |
Thank you for your clarification. However I went ahead and implemented a simple fix for this issue in my own fork, and it has been working well for me so far Would you be open to reviewing a pull request for this? Thank you for your time. |
@xckomorebi I would be willing to review a fix, provided:
Sorry for being so demanding, but since we are trying not to devote resources to GOPATH, we can only accept CLs that come in narrowly scoped, tested, and correct. |
I should add though: it does look like you've found the relevant place where PkgPath is being misinterpreted. The subtlety here is that a PkgPath (=linker path) is not the same as an Import path, and you have found exactly where the two are conflated. |
gopls version
Build info
golang.org/x/tools/gopls (devel)
golang.org/x/tools/gopls@(devel)
github.com/BurntSushi/toml@v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=
github.com/google/go-cmp@v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
golang.org/x/exp/typeparams@v0.0.0-20241210194714-1829a127f884 h1:1xaZTydL5Gsg78QharTwKfA9FY9CZ1VQj6D/AZEvHR0=
golang.org/x/mod@v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
golang.org/x/sync@v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
golang.org/x/telemetry@v0.0.0-20241220003058-cc96b6e0d3d9 h1:L2k9GUV2TpQKVRGMjN94qfUMgUwOFimSQ6gipyJIjKw=
golang.org/x/text@v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/tools@v0.28.0 => ../
golang.org/x/vuln@v1.1.3 h1:NPGnvPOTgnjBc9HTaUx+nj+EaUYxl5SJOWqaDYGaFYw=
honnef.co/go/tools@v0.5.1 h1:4bH5o3b5ZULQ4UrBmP+63W9r7qIkqJClEA9ko5YKx+I=
mvdan.cc/gofumpt@v0.7.0 h1:bg91ttqXmi9y2xawvkuMXyvAA/1ZGJqYAEGjXuP0JXU=
mvdan.cc/xurls/v2@v2.5.0 h1:lyBNOm8Wo71UknhUs4QTFUNNMyxy2JEIaKKo0RWOh+8=
go: go1.23.5
golang.org/x/tools commit hash: 8171d94fe98a51fb8471b40726983dd098a3fde6
go env
What did you do?
working in a repo with the following structure.
What did you see happen?
If I accept the completion, it will import "bar" from "github.com/foo/vendor/github.com/bar" instead of "github.com/bar"
What did you expect to see?
gopls should treat modules from the vendor path as normal modules.
I added a test case that reproduces the bug and noticed it only occurs when the cache is used.
golang/tools@master...xckomorebi:tools:master
Editor and settings
No response
Logs
No response
The text was updated successfully, but these errors were encountered: