You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update release notes and feature documentation for change signature
refactoring and support changes.
For golang/go#70301
Change-Id: I1a4543e317f1016cdd5631640307b60435f1b23e
Reviewed-on: https://go-review.googlesource.com/c/tools/+/633376
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Gopls reports some code actions twice, with two different kinds, so
87
91
that they appear in multiple UI elements: simplifications,
@@ -99,6 +103,7 @@ that, in the course of reporting a diagnostic about a problem,
99
103
also suggest a fix.
100
104
A `codeActions` request will return any fixes accompanying diagnostics
101
105
for the current selection.
106
+
102
107
<!-- Some gopls-internal analyzers compute fixes lazily by
103
108
reporting an empty list of TextEdits and a Diagnostic.Category
104
109
recognized by gopls that enables corresponding logic in the
@@ -117,6 +122,7 @@ for the current selection.
117
122
-->
118
123
119
124
Caveats:
125
+
120
126
- Many of gopls code transformations are limited by Go's syntax tree
121
127
representation, which currently records comments not in the tree
122
128
but in a side table; consequently, transformations such as Extract
@@ -158,10 +164,12 @@ Most clients are configured to format files and organize imports
158
164
whenever a file is saved.
159
165
160
166
Settings:
167
+
161
168
- The [`gofumpt`](../settings.md#gofumpt) setting causes gopls to use an
162
169
alternative formatter, [`github.com/mvdan/gofumpt`](https://pkg.go.dev/mvdan.cc/gofumpt).
163
170
164
171
Client support:
172
+
165
173
-**VS Code**: Formats on save by default. Use `Format document` menu item (`⌥⇧F`) to invoke manually.
166
174
-**Emacs + eglot**: Use `M-x eglot-format-buffer` to format. Attach it to `before-save-hook` to format on save. For formatting combined with organize-imports, many users take the legacy approach of setting `"goimports"` as their `gofmt-command` using [go-mode](https://github.com/dominikh/go-mode.el), and adding `gofmt-before-save` to `before-save-hook`. An LSP-based solution requires code such as https://github.com/joaotavora/eglot/discussions/1409.
167
175
-**CLI**: `gopls format file.go`
@@ -194,6 +202,7 @@ Settings:
194
202
should appear after standard and third-party packages in the sort order.
195
203
196
204
Client support:
205
+
197
206
-**VS Code**: automatically invokes `source.organizeImports` before save.
198
207
To disable it, use the snippet below, and invoke the "Organize Imports" command manually as needed.
199
208
```
@@ -243,7 +252,7 @@ boolean.
243
252
244
253
**Method receivers**: When testing a method `T.F` or `(*T).F`, the test must
245
254
construct an instance of T to pass as the receiver. Gopls searches the package
246
-
for a suitable function that constructs a value of type T or *T, optionally with
255
+
for a suitable function that constructs a value of type T or \*T, optionally with
247
256
an error, preferring a function named `NewT`.
248
257
249
258
**Imports**: Gopls adds missing imports to the test file, using the last
@@ -305,9 +314,10 @@ Similar problems may arise with packages that use reflection, such as
305
314
judgment and testing.
306
315
307
316
Some tips for best results:
317
+
308
318
- There is currently no special support for renaming all receivers of
309
319
a family of methods at once, so you will need to rename one receiver
310
-
one at a time (golang/go#41892).
320
+
one at a time (golang/go#41892).
311
321
- The safety checks performed by the Rename algorithm require type
312
322
information. If the program is grossly malformed, there may be
313
323
insufficient information for it to run (golang/go#41870),
@@ -328,12 +338,12 @@ in the latter half of this 2015 GothamGo talk:
328
338
[Using go/types for Code Comprehension and Refactoring Tools](https://www.youtube.com/watch?v=p_cz7AxVdfg).
329
339
330
340
Client support:
341
+
331
342
-**VS Code**: Use "[Rename symbol](https://code.visualstudio.com/docs/editor/editingevolved#_rename-symbol)" menu item (`F2`).
332
343
-**Emacs + eglot**: Use `M-x eglot-rename`, or `M-x go-rename` from [go-mode](https://github.com/dominikh/go-mode.el).
333
344
-**Vim + coc.nvim**: Use the `coc-rename` command.
0 commit comments