x/tools/gopls: expands workspace to the wrong root when go.mod file is above go.work. #63917
Labels
gopls/metadata
Issues related to metadata loading 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.
Milestone
The following bug was discovered in golang/vscode-go#2884:
output.txt
:happy_output.txt
:In other words, it looks like the same query, from the same workspace, is returning different results.
Digging deeper, I found it:
output.txt
:happy_output.txt
:The "go dir" is being computed incorrectly. That logic is here:
https://cs.opensource.google/go/x/tools/+/master:gopls/internal/lsp/cache/view.go;l=1005;drc=cf5aad9d898a74d0f6cd041af86762f1122b926a
So @Kindred87 can you please confirm that you have a
go.mod
file inC:\\Users\\Kindred87\\OneDrive - Company\\Projects\\Project Name
? If that is the case, then gopls is expanding the workspace to the wrong directory. Adding another go.mod file truncates the search, as you discovered.Gopls should instead be truncating that expansion at a go.work file, if present. This is just a bug, though we probably don't hit it that often as
go.mod > go.work
is relatively unlikely. All of this is being rewritten right now in https://go.dev/issue/57979, so I'm not sure if it is worth fixing this bug, which has been present for a long time. Soon gopls will "do the right thing always"...Originally posted by @findleyr in golang/vscode-go#2884 (comment)
The text was updated successfully, but these errors were encountered: