Gopls release v0.25.0 (expected Jan 2027)
In this release:
Key features are described below.
Configuration changes
Gopls now debounces bursts of workspace/didChangeWatchedFiles
notifications (such as those produced during a git checkout) within a
short window before recomputing diagnostics. The new watchedFileDelay
setting (default "50ms") controls this window; setting it to "0s"
disables debouncing.
The -debug=address flag and the gopls.start_debugging command now
reject an implicit host (e.g. :0), like -listen does. You must
explicitly specify a host such as 0.0.0.0 or (preferably) localhost.
Passive features
Editing features
Analysis features
unusedfunc analyzer also reports unused struct fields
The existing unusedfunc analyzer now additionally reports a
diagnostic for each unexported field of a named struct type that is
never referenced within its package. (An unkeyed struct literal
T{x, y} counts as an implicit use.)
Code transformation features
Move declaration
The new interactive “Move declaration” code action
(refactor.move.moveDeclaration) moves a top-level function, method,
type, variable, or constant declaration to another file, which may be in
the same package or a different one.
If the cursor or selection is within a declaration D, gopls offers the “Move declaration D” code action. When you invoke it, gopls prompts you for the destination file. If the file or its package doesn’t exist yet, gopls creates it.
When the destination file is in a different package, moving the target declaration by itself could break the build, so gopls moves additional symbols into the destination file along with it:
- Coupled symbols, which have to move as a group. For example, a
type and all of its methods, or every constant in an
iotablock. Moving a method to another package also moves its receiver type and the type’s other methods. - Dependent symbols: top-level declarations in the source package that the moved declarations refer to, found transitively. These move even if other code in the source package still uses them.
Gopls then updates every reference to the moved symbols, in the source package, the destination package, and any other importing packages, and adds or removes imports as needed. If code left behind in the source package still refers to any of the moved symbols, the source package will now import the destination package. Doc comments and trailing comments move with their declarations.
Gopls rejects the move if it would break the build. For example, the move fails if it would create an import cycle, break the internal import rule, cause a name conflict in the destination package, or leave code in the source package referring to an unexported symbol that has moved.
This feature requires a client that supports the interactive dialogs extension to LSP.
The same refactoring is available from the command line through the new
gopls move_decl subcommand, which takes a target symbol and a
destination file:
$ gopls move_decl example.com/a.Foo b/b.go
$ gopls move_decl -pkg example.com/a Foo b/b.go
Unlike other subcommands that edit files, move_decl does not support the
-write or -diff flags; it always writes its edits directly to the files.
Model context protocol (MCP) features
All MCP tools now set the readOnlyHint annotation, since none of
them modify the workspace. (go_rename_symbol returns the edits
as a diff for the client to apply.) Some clients that ask for
approval before running tools that are not read-only can now run
the gopls tools without prompting.
The source files for this documentation can be found beneath golang.org/x/tools/gopls/doc.