The experimental hoverKind=Structured
setting is no longer supported.
The gc_details
code lens has been deleted. (It was previously disabled by default.) This functionality is now available through the settings.toggleCompilerOptDetails
code action (documented below), as code actions are better supported than code lenses across a range of clients.
VS Code's special “Go: Toggle GC details” command continues to work.
This code action, accessible through the “Source Action” menu in VS Code, toggles a per-package flag that causes Go compiler optimization details to be reported as diagnostics. For example, it indicates which variables escape to the heap, and which array accesses require bounds checks.
modernize
analyzerGopls now reports when code could be simplified or clarified by using more modern features of Go, and provides a quick fix to apply the change.
Examples:
min
or max
built-in functions added in Go 1.18;unusedfunc
analyzerGopls now reports unused functions and methods, giving you near real-time feedback about dead code that may be safely deleted. Because the analysis is local to each package, only unexported functions and methods are candidates. (For a more precise analysis that may report unused exported functions too, use the golang.org/x/tools/cmd/deadcode
command.)
At long last, the “Go to Implementations” feature now fully supports generic types and functions (#59224).
For example, invoking the feature on the interface method Stack.Push
below will report the concrete method C[T].Push
, and vice versa.
package p
type Stack[T any] interface {
Push(T) error
Pop() (T, bool)
}
type C[T any] struct{}
func (C[T]) Push(t T) error { ... }
func (C[T]) Pop() (T, bool) { ... }
var _ Stack[int] = C[int]{}
When you have multiple instances of the same expression in a function, you can use this code action to extract it into a variable. All occurrences of the expression will be replaced with a reference to the new variable.
The Definition query now supports additional locations:
When invoked on a return statement, hover reports the types of the function's result variables.