Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
x/tools/gopls: gopls.gc_details back doesn't clear all gc details #42198
How to reproduce (using vscode)
First `gopls.gc_details` with `net/http/server_test.go`
Second `gopls.gc_details` with `net/http/server_test.go`
What you expected
As soon as I opened the file by clicking one of the left-over gc details diagnostic messages, the left-over gc details on the package disappeared.
go version: tip
I have reproduced this:
I'm using the latest gopls and the latest vscod-go and the latest code-insiders.
There are two ways of computing diagnostics, controlled by a boolean 'withAnalysis'. If a file is open in the editor, its (package's) diagnostics are computed withAnalysis true. So in this case, diagnostics for net/http are computed withAnalysis true. The details are computed for the directory net/http, but include details for net/dial.go, but as all the diagnostics for net/http are packaged together, these count as having withAnalysis true also.
Then when gc_details is turned off, the diagnostics are recomputed, and there are none for net/dial.go. But gopls sees that the previous diagnostics for net/dial.go were done withAnalysis true, so it believes the new diagnostics are less precise, so doesn't send them.
That is, the diagnostics for net/dial.go were sent originally as part of diagnostics on a different package (http, which has a visible file) and withAnalysis true, and the new diagnostics are on package net where withAnalysis is false.
If this is right, the problem occurs when gc_detaills is turned off. There seem to be two approaches:
Alas, it is harder than that. B doesn't work easily as we need to get empty diagnostics sent. Changing the remembered diagnostics doesn't help enough. And it's even worse: in the current source distribution gc_details also creates a diagnostic for vendor/golang.org/x/net/http/httproxy/proxy.go, and the regular diagnostics never produce anything for that, not even empty diagnostics, so there's no way to turn them off in vscode.