fieldalignment
analyzer, previously disabled by default, has been removed: it is redundant with the hover size/offset information displayed by v0.16.0 and its diagnostics were confusing.refactor.inline
to refactor.inline.call
. This allows clients to request particular code actions more precisely. The user manual now includes the identifier in the documentation for each code action.allowImplicitNetworkAccess
setting is removed, following its deprecation in gopls@v0.16.0. See golang/go#66861 for details.TODO(rfindley): document the state of change signature refactoring once the feature set stabilizes.
TODO(rfindley): document the full set of improvements to rename/extract/inline.
Gopls now offers another code action, “Extract declarations to new file” (refactor.extract.toNewFile
), which moves selected code sections to a newly created file within the same package. The created filename is chosen as the first {function, type, const, var} name encountered. In addition, import declarations are added or removed as needed.
The user can invoke this code action by selecting a function name, the keywords func
, const
, var
, type
, or by placing the caret on them without selecting, or by selecting a whole declaration or multiple declarations.
In order to avoid ambiguity and surprise about what to extract, some kinds of paritial selection of a declaration cannot invoke this code action.
When the selection is a constant expression, gopls now offers “Extract constant” instead of “Extract variable”, and generates a const
declaration instead of a local variable.
Also, extraction of a constant or variable now works at top-level, outside of any function.
When initialized with the option "pullDiagnostics": true
, gopls will advertise support for the textDocument.diagnostic
client capability, which allows editors to request diagnostics directly from gopls using a textDocument/diagnostic
request, rather than wait for a textDocument/publishDiagnostics
notification. This feature is off by default until the performance of pull diagnostics is comparable to push diagnostics.
The textDocument/hover
response has slightly tweaked markdown rendering, and includes the following additional information:
errors.As
shows “Added in go1.13”.The semantic tokens response now includes additional modifiers for the top-level constructor of the type of each symbol: interface
, struct
, signature
, pointer
, array
, map
, slice
, chan
, string
, number
, bool
, and invalid
. Editors may use this for syntax coloring.
Now, function signature help can be used on any identifier with a function signature, not just within the parentheses of a function being called.
A Definition query on a reference to a function jumps to the function's Go func
declaration. If the function is implemented in C or assembly, the function has no body. Executing a second Definition query (while already at the Go declaration) will navigate you to the assembly implementation.
When you attempt to call a method on a type that does not have that method, the compiler will report an error like “type X has no field or method Y”. Gopls now offers a new code action, “Declare missing method of T.f”, where T is the concrete type and f is the undefined method. The stub method's signature is inferred from the context of the call.
yield
analyzerThe new yield
analyzer detects mistakes using the yield
function in a Go 1.23 iterator, such as failure to check its boolean result and break out of a loop.
waitgroup
analyzerThe new waitgroup
analyzer detects calls to the Add
method of sync.WaitGroup
that are (mistakenly) made within the new goroutine, causing Add
to race with Wait
. (This check is equivalent to staticcheck's SA2000, but is enabled by default.)
If the selected chunk of code is part of a function or method declaration F, gopls will offer the “Add test for F” code action, which adds a new test for the selected function in the corresponding _test.go
file. The generated test takes into account its signature, including input parameters and results.
Since this feature is implemented by the server (gopls), it is compatible with all LSP-compliant editors. VS Code users may continue to use the client-side Go: Generate Unit Tests For file/function/package
command which utilizes the gotests tool.