-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/tools/gopls: support gofmt -s
in formatting
#37221
Comments
Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here. |
"go.formatTool": "gofmt",
"go.formatFlags": ["-s"], You can disable "go.experimentalLanguageServerFeatures": {
"format": false,
} |
gofmt -s
in formatting
/cc @ridersofrohan |
Change https://golang.org/cl/223658 mentions this issue: |
Change https://golang.org/cl/223659 mentions this issue: |
Change https://golang.org/cl/223660 mentions this issue: |
Change https://golang.org/cl/223661 mentions this issue: |
This change adds support for analyzers that have suggested fixes of the kind Source.FixAll. This will allow these fixes to be applied on save if the user desires. To auto apply these fixes on save, make sure your settings.json looks like: "[go]": { "editor.codeActionsOnSave": { ... "source.fixAll": true, ... }, ... } Update golang/go#37221 Change-Id: I534e4f6c8c51ec2848cf2899aab68f587ba68423 Reviewed-on: https://go-review.googlesource.com/c/tools/+/223658 Run-TryBot: Rohan Challa <rohan@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This is one of the simplifications that "gofmt -s" applies. https://golang.org/cmd/gofmt/#hdr-The_simplify_command A range of the form: for x, _ = range v {...} will be simplified to: for x = range v {...} A range of the form: for _ = range v {...} will be simplified to: for range v {...} Updates golang/go#37221 Change-Id: Ic6babbd0b8ab961ebb4d0d6df72df52d9acde6e7 Reviewed-on: https://go-review.googlesource.com/c/tools/+/223661 Run-TryBot: Rohan Challa <rohan@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This is one of the simplifications that "gofmt -s" applies. https://golang.org/cmd/gofmt/#hdr-The_simplify_command An array, slice, or map composite literal of the form: []T{T{}, T{}} will be simplified to: []T{{}, {}} Updates golang/go#37221 Change-Id: I2dca46501983c8af3581c9319d973da5cf690388 Reviewed-on: https://go-review.googlesource.com/c/tools/+/223660 Run-TryBot: Rohan Challa <rohan@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
This is one of the simplifications that "gofmt -s" applies. https://golang.org/cmd/gofmt/#hdr-The_simplify_command A slice expression of the form: s[a:len(s)] will be simplified to: s[a:] Updates golang/go#37221 Change-Id: Ibd4dedaadc9b129d5d39524f0c1ccc8a95bf7e0d Reviewed-on: https://go-review.googlesource.com/c/tools/+/223659 Run-TryBot: Rohan Challa <rohan@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org>
Utility "gopls" used to analyse Go source did not support code simplifications as of writing "sslendpoints" tool [1]. Simplifying composite literals is now supported [2]. [1] golang/go#37221 [2] golang/tools@e428a8e Issue-ID: SECCOM-261 Change-Id: I757ff8aefed4c7653f3992f9c1b7b0f3e6c10ea3 Signed-off-by: Pawel Wieczorek <p.wieczorek2@samsung.com>
Utility "gopls" used to analyse Go source did not support code simplifications as of writing "sslendpoints" tool [1]. Simplifying composite literals is now supported [2]. [1] golang/go#37221 [2] golang/tools@e428a8e Issue-ID: SECCOM-261 Change-Id: I757ff8aefed4c7653f3992f9c1b7b0f3e6c10ea3 Signed-off-by: Pawel Wieczorek <p.wieczorek2@samsung.com> (cherry picked from commit 8ff725b)
What version of Go are you using (
go version
)?What version of gopls are you using (
gopls version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Given settings.json with
I save my file
What did you expect to see?
Properly formatted code
What did you see instead?
Nothing changes, causing our CI to complain that the files was not formatted using gofmt -s
Relevant logs
gopls -rpc.trace -v check #file#
Outputgopls logs
OutputThe text was updated successfully, but these errors were encountered: