Open rustyx opened 6 months ago
I wonder if this is related to #53004.
cc: @findleyr
Sorry, but this didn't reproduce for me, with either VS Code or coc.nvim. (EDIT: to be clear: both of my test clients behaved as expected, and I could navigate to Must, NewRandom, etc)
Which LSP client are you using? Can you please also share the output of gopls -v version
?
I have the latest gopls
.
Apologies for the confusion, indeed the issue actually arises only after I add the go/pkg/mod
folder to the current workspace.
Try these Steps to reproduce:
$HOME/go/pkg/mod/
to the workspace.main.go
, place the cursor at uuid.New()
, press F12, then on NewRandom()
, press F12 again.@findleyr LSP client is VSCode (v1.88.1) running on Ubuntu Linux 22.04 amd64. Again apologies for not mentioning it upfront. I think the issue is specific to VSCode and having go/pkg/mod mapped as a project in the current workspace.
My current LSP session state looks like this:
Session 1
From: Cache 1
Views
ID: 1 Type: GoModView Root: file:///home/user/src/issue-66827 Folder: issue-66827:file:///home/user/src/issue-66827 ID: 2 Type: AdHocView Root: file:///home/user/go/pkg/mod Folder: mod:file:///home/user/go/pkg/mod ID: 4 Type: GoModView Root: file:///home/user/go/pkg/mod/github.com/google/uuid@v1.6.0 Folder: mod:file:///home/user/go/pkg/mod
Overlays
file:///home/user/go/pkg/mod/github.com/google/uuid@v1.6.0/version4.go file:///home/user/src/issue-66827/main.go
This issue is reproducible only when $HOME/go/pkg/mod/ is added to the workspace. Seems like gopls doesn't processes the module cache and it may not be the recommended way to navigate function definition.
Indeed, I'll check that we're handling this correctly.
Since this is unlikely to affect a large number of users, I'll move this to a future release milestone.
Consider a Go project with
main.go
looking like this:When I go to definition (F12) of
uuid.New()
I end up here:So far so good.
But when I try to navigate futher to
Must
orNewRandom
, I get a popup "No definition found...".Whereas if I navigate to
fmt.Println
, I can navigate further intoFprintln
,doPrintln
,writeByte
, etc.Why is this difference in behavior between Go SDK packages and imported modules?
Shouldn't I be able to navigate within modules the same way I do in my own code and the Go SDK?
gopls version: v0.15.2
go version: 1.22
The full test project can be found at https://github.com/rustyx/issue-66827