Debian Codegraph @

gopls/doc/release/v0.22.0.md

raw symbols SCIP
1 ---
2 title: "Gopls release v0.22.0 (May 2026)"
3 ---
4
5 In this release:
6
7 - [commits](https://go.googlesource.com/tools/+log/refs/heads/gopls-release-branch.0.21..refs/heads/gopls-release-branch.0.22)
8 - [issues closed](https://github.com/golang/go/milestone/415?closed=1) (plus
9 a number of modernizer fixes in the [go1.26 milestone](https://github.com/golang/go/milestone/408?closed=1)).
10
11 Key features are described below.
12 Much of the work of this, as usual, consists of numerous small bug fixes.
13
14 We are pleased to report that crash stability has improved so much in
15 recent years that the fraction of gopls telemetry reports clearly due
16 to hardware failure is significant and growing.
17
18 ## Interactive code transformations
19 <!-- golang/go#76331 -->
20 This release includes support for a non-standard LSP feature that
21 allows code actions to have [interactive dialogs](https://go.dev/issue/76331).
22 We expect this to enable all kinds of new features, such as analyzers
23 that prompt for additional preferences or intent, or code
24 transformations that ask for advice on how to resolve ambiguities.
25
26 This release includes three interactive code actions:
27 - **Add tags to struct fields**: Prompts the user for the tags to add and
28 the casing transformation rule (e.g., `camelCase`, `snake_case`).
29 - **Remove tags from struct fields**: Prompts the user for the tags to remove.
30 - **Implement interface**: A new code action that adds method stubs to a type
31 to implement a specified interface
32 (see [golang/vscode-go#1547](https://github.com/golang/vscode-go/issues/1547)).
33
34 Dialog support is a non-standard feature of LSP.
35 It is currently supported only by `gopls` and requires a language
36 client (such as VS Code) that supports the proposed protocol.
37 We plan to work with the broader LSP community to develop other LSP
38 clients (editors) and servers to refine the design and support dialogs
39 as a standard part of the protocol.
40
41 ## Changes to module requirements trigger vulnerability scanning
42
43 Gopls now detects changes in the go.mod requirements.
44 The first time gopls sees a new configuration, for example after a
45 dependency is upgraded, it will prompt to run [vulnerability
46 scanning](https://go.dev/blog/govulncheck).
47
48 If you prefer to avoid interactive prompts, opt for "always" or
49 "never" and your choice will be saved persistently in the user's
50 configuration directory (beneath `os.UserConfigDir`).
51
52 The set of available code lenses now includes `run_govulncheck` by default.
53
54 ## Configuration changes
55
56 - The default value for the `vulncheck` setting is now `"Prompt"` (see above).
57 - The `fieldassignment` analyzer is back by popular demand, though still off by default.
58 - The experimental `renameMovesSubpackages` setting determines whether
59 a package-rename operation should also move subdirectories.
60 - The `importsSource` setting is deprecated and will be removed in the next release.
61 - The `-port=int` debugging flag (redundant with `-listen`) has been removed.
62 - The `-listen=address` flag now rejects an implicit host (e.g. `:0`).
63 You must explicitly specify a host such as `0.0.0.0` or (preferably) `localhost`
64 - When the `semanticTokens` setting is disabled (the default), the server
65 no longer advertises the semantic token capability during server initialization.
66 This prevents the client from sending unnecessary requests.
67
68 ## Navigation features
69
70 - In a go.mod file, requesting References while hovering over the name of
71 a module in a `require` declaration will report all the imports of
72 that module in the module defined by the go.mod file.
73 <!-- golang/go#75810 -->
74
75 ## Analysis features
76
77 ### `atomictypes` analyzer
78 <!-- golang/go#77352 -->
79 The new `atomictypes` analyzer suggests replacing the primitive `sync/atomic` functions with
80 the strongly typed atomic wrapper types introduced in Go1.19 such as `atomic.Int32`.
81 The analyzer's fixes change declarations like `var x int32` to `var x
82 atomic.Int32` and update corresponding call sites from
83 `atomic.AddInt32(&x, 1)` to method calls like `x.Add(1)`.
84
85 ### `embedlit` modernizer
86 <!-- golang/go#77965 -->
87 The new `embedlit` modernizer suggests removing embedded field type specifiers
88 from composite literals when they are redundant under the rules of Go 1.27,
89 which introduces the ability to directly initialize fields promoted from
90 embedded struct types without a nested literal.
91
92 ### `fieldassignment` analyzer
93 <!-- golang/go#76237 -->
94 The fieldassignment analyzer, which reports diagnostics about memory layout and
95 was disabled in v0.17.0, has been restored. It is disabled by default.
96 (Hovering over the declaration of a struct type or its individual fields
97 continues to reveal its size/class/offset information.)
98
99 ### `scannererr` analyzer
100 <!-- golang/go#17747 -->
101 The scannererr analyzer reports failure to call the Err method when
102 calling the Scan method of bufio.Scanner in a loop.
103
104 ### `writestring` analyzer
105 <!-- golang/go#77369 -->
106 The new writestring analyzer detects inefficient string concatenation in uses of WriteString,
107 of the form WriteString(a+b), and offers to replace them with WriteString(a); WriteString(b).
108
109 ### `waitgroup` modernizer renamed to `waitgroupgo`
110 <!-- golang/go#77560 -->
111 Previously there were two analyzers named `waitgroup`: an analyzer that checks
112 for misuses of `sync.WaitGroup`, and a modernizer that simplifies goroutine
113 management with `sync.WaitGroup`. We have renamed the modernizer to `waitgroupgo`.
114
115 ### `stringscut` modernizer now handles `Split` and `SplitN`
116 The existing `stringscut` modernizer now replaces calls such as
117 `strings.Split(s, ":")[0]` or `strings.SplitN(s, ":", 2)[0]` with Go
118 1.18's `strings.Cut(s, ":")`, which is more efficient since it doesn't
119 need to allocate a short-lived array.
120
121 ### `yield` analyzer improved precision
122 The `yield` analyzer, which detects problems in iterators that fail to
123 stop once `yield()` returns false, has been rewritten as a non-sparse
124 Killdall-style monotone dataflow analysis, improving its precision.
125
126 ## Server-side file watching
127
128 Gopls introduces an experimental server-side file watching mechanism to monitor file system events directly. This feature supplements standard LSP file change notifications in environments or editor clients where client-side events may be unreliable or dropped.
129
130 This feature is configured via the internal setting `fileWatcher`, which supports three strategies:
131 - `"off"` (default): the client is solely responsible for change notification
132 - `"poll"`: the server periodically scans workspace directories, using optimizations similar to `git status`
133 - `"fsnotify"`: the server uses kernel support for file-change notification. This strategy is system dependent and may need to open many directories to watch a large workspace, risking [file descriptor exhaustion](https://github.com/fsnotify/fsnotify#kqueue-macos-all-bsd-systems)