Skip to content

Commit 82473ce

Browse files
adonovangopherbot
authored andcommitted
gopls/doc/release: tweak v0.19
Updates golang/go#73965 Change-Id: I532438e160a99bb1754d1de4ed9015eae3880fb9 Reviewed-on: https://go-review.googlesource.com/c/tools/+/678759 Reviewed-by: Robert Findley <[email protected]> Auto-Submit: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent f3c581f commit 82473ce

File tree

1 file changed

+101
-78
lines changed

1 file changed

+101
-78
lines changed

gopls/doc/release/v0.19.0.md

Lines changed: 101 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,15 @@
11
# Configuration Changes
22

3-
- The `gopls check` subcommant now accepts a `-severity` flag to set a minimum
3+
- The `gopls check` subcommand now accepts a `-severity` flag to set a minimum
44
severity for the diagnostics it reports. By default, the minimum severity
55
is "warning", so `gopls check` may report fewer diagnostics than before. Set
66
`-severity=hint` to reproduce the previous behavior.
77

8-
# New features
8+
# Navigation features
99

10-
## "Rename" of method receivers
10+
## "Implementations" supports signature types (within same package)
1111

12-
The Rename operation, when applied to the declaration of a method
13-
receiver, now also attempts to rename the receivers of all other
14-
methods associated with the same named type. Each other receiver that
15-
cannot be fully renamed is quietly skipped.
16-
17-
Renaming a _use_ of a method receiver continues to affect only that
18-
variable.
19-
20-
```go
21-
type Counter struct { x int }
22-
23-
Rename here to affect only this method
24-
25-
func (c *Counter) Inc() { c.x++ }
26-
func (c *Counter) Dec() { c.x++ }
27-
28-
Rename here to affect all methods
29-
```
30-
31-
## Many `staticcheck` analyzers are enabled by default
32-
33-
Slightly more than half of the analyzers in the
34-
[Staticcheck](https://staticcheck.dev/docs/checks) suite are now
35-
enabled by default. This subset has been chosen for precision and
36-
efficiency.
37-
38-
Previously, Staticcheck analyzers (all of them) would be run only if
39-
the experimental `staticcheck` boolean option was set to `true`. This
40-
value continues to enable the complete set, and a value of `false`
41-
continues to disable the complete set. Leaving the option unspecified
42-
enables the preferred subset of analyzers.
43-
44-
Staticcheck analyzers, like all other analyzers, can be explicitly
45-
enabled or disabled using the `analyzers` configuration setting; this
46-
setting now takes precedence over the `staticcheck` setting, so,
47-
regardless of what value of `staticcheck` you use (true/false/unset),
48-
you can make adjustments to your preferred set of analyzers.
49-
50-
## "Inefficient recursive iterator" analyzer
51-
52-
A common pitfall when writing a function that returns an iterator
53-
(iter.Seq) for a recursive data type is to recursively call the
54-
function from its own implementation, leading to a stack of nested
55-
coroutines, which is inefficient.
56-
57-
The new `recursiveiter` analyzer detects such mistakes; see
58-
[https://golang.org/x/tools/gopls/internal/analysis/recursiveiter](its
59-
documentation) for details, including tips on how to define simple and
60-
efficient recursive iterators.
61-
62-
## "Inefficient range over maps.Keys/Values" analyzer
63-
64-
This analyzer detects redundant calls to `maps.Keys` or `maps.Values`
65-
as the operand of a range loop; maps can of course be ranged over
66-
directly.
67-
68-
## "Implementations" supports signature types
12+
<!-- golang/go#56572 -->
6913

7014
The Implementations query reports the correspondence between abstract
7115
and concrete types and their methods based on their method sets.
@@ -89,9 +33,11 @@ Queries using method-sets should be invoked on the type or method name,
8933
and queries using signatures should be invoked on a `func` or `(` token.
9034

9135
Only the local (same-package) algorithm is currently supported.
92-
TODO: implement global.
36+
(https://go.dev/issue/56572 tracks the global algorithm.)
9337

94-
## Go to Implementation
38+
## "Go to Implementation" reports interface-to-interface relations
39+
40+
<!-- golang/go#68641 -->
9541

9642
The "Go to Implementation" operation now reports relationships between
9743
interfaces. Gopls now uses the concreteness of the query type to
@@ -126,19 +72,102 @@ of the selected named type.
12672

12773
<img title="Type Hierarchy: subtypes of io.Writer" src="../assets/subtypes.png" width="400">
12874

129-
## "Eliminate dot import" code action
13075

131-
This code action, available on a dotted import, will offer to replace
132-
the import with a regular one and qualify each use of the package
133-
with its name.
76+
# Editing features
13477

135-
### Auto-complete package clause for new Go files
78+
## Completion: auto-complete package clause for new Go files
13679

13780
Gopls now automatically adds the appropriate `package` clause to newly created Go files,
13881
so that you can immediately get started writing the interesting part.
13982

14083
It requires client support for `workspace/didCreateFiles`
14184

85+
## New GOMODCACHE index for faster Organize Imports and unimported completions
86+
87+
By default, gopls now builds and maintains a persistent index of
88+
packages in the module cache (GOMODCACHE). The operations of Organize
89+
Imports and completion of symbols from unimported pacakges are an
90+
order of magnitude faster.
91+
92+
To revert to the old behavior, set the `importsSource` option (whose
93+
new default is `"gopls"`) to `"goimports"`. Users who don't want the
94+
module cache used at all for imports or completions can change the
95+
option to "off".
96+
97+
# Analysis features
98+
99+
## Most `staticcheck` analyzers are enabled by default
100+
101+
Slightly more than half of the analyzers in the
102+
[Staticcheck](https://staticcheck.dev/docs/checks) suite are now
103+
enabled by default. This subset has been chosen for precision and
104+
efficiency.
105+
106+
Previously, Staticcheck analyzers (all of them) would be run only if
107+
the experimental `staticcheck` boolean option was set to `true`. This
108+
value continues to enable the complete set, and a value of `false`
109+
continues to disable the complete set. Leaving the option unspecified
110+
enables the preferred subset of analyzers.
111+
112+
Staticcheck analyzers, like all other analyzers, can be explicitly
113+
enabled or disabled using the `analyzers` configuration setting; this
114+
setting now takes precedence over the `staticcheck` setting, so,
115+
regardless of what value of `staticcheck` you use (true/false/unset),
116+
you can make adjustments to your preferred set of analyzers.
117+
118+
## `recursiveiter`: "inefficient recursive iterator"
119+
120+
A common pitfall when writing a function that returns an iterator
121+
(`iter.Seq`) for a recursive data type is to recursively call the
122+
function from its own implementation, leading to a stack of nested
123+
coroutines, which is inefficient.
124+
125+
The new `recursiveiter` analyzer detects such mistakes; see
126+
[its documentation](https://golang.org/x/tools/gopls/internal/analysis/recursiveiter)
127+
for details, including tips on how to define simple and efficient
128+
recursive iterators.
129+
130+
## `maprange`: "inefficient range over maps.Keys/Values"
131+
132+
The new `maprange` analyzer detects redundant calls to `maps.Keys` or
133+
`maps.Values` as the operand of a range loop; maps can of course be
134+
ranged over directly. See
135+
[its documentation](https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/maprange)
136+
for details).
137+
138+
# Code transformation features
139+
140+
## Rename method receivers
141+
142+
<!-- golang/go#41892 -->
143+
144+
The Rename operation, when applied to the declaration of a method
145+
receiver, now also attempts to rename the receivers of all other
146+
methods associated with the same named type. Each other receiver that
147+
cannot be fully renamed is quietly skipped.
148+
149+
Renaming a _use_ of a method receiver continues to affect only that
150+
variable.
151+
152+
```go
153+
type Counter struct { x int }
154+
155+
Rename here to affect only this method
156+
157+
func (c *Counter) Inc() { c.x++ }
158+
func (c *Counter) Dec() { c.x++ }
159+
160+
Rename here to affect all methods
161+
```
162+
163+
## "Eliminate dot import" code action
164+
165+
<!-- golang/go#70319 -->
166+
167+
This code action, available on a dotted import, will offer to replace
168+
the import with a regular one and qualify each use of the package
169+
with its name.
170+
142171
## Add/remove tags from struct fields
143172

144173
Gopls now provides two new code actions, available on an entire struct
@@ -156,6 +185,8 @@ type Info struct {
156185

157186
## Inline local variable
158187

188+
<!-- golang/go#70085 -->
189+
159190
The new `refactor.inline.variable` code action replaces a reference to
160191
a local variable by that variable's initializer expression. For
161192
example, when applied to `s` in `println(s)`:
@@ -174,14 +205,6 @@ func f(x int) {
174205
}
175206
```
176207

177-
## Use index for GOMODCACHE in imports and unimported completions
178-
179-
The default for the option `importsSource` changes from "goimports" to "gopls".
180-
This has the effect of building and maintaining an index to
181-
the packages in GOMODCACHE.
182-
The index is stored in the directory `os.UserCacheDir()/go/imports`.
183-
Users who want the old behavior can change the option back. Users who don't
184-
the module cache used at all for imports or completions
185-
can change the option to
186-
"off". The new code is many times faster than the old when accessing the
187-
module cache.
208+
Only a single reference is replaced; issue https://go.dev/issue/70085
209+
tracks the feature to "inline all" uses of the variable and eliminate
210+
it.

0 commit comments

Comments
 (0)