Closed Graham42 closed 4 years ago
Thanks for the report. The language server now does this though a source.FixAll
code action, so you will need to add the following to the your "[go]"
settings block:
"[go]": {
"editor.codeActionsOnSave": {
"source.fixAll": true,
},
},
Thanks! That snippet solves the "on save" use case for me. However, if I use the editor "Format Document" command the -s
flag is still not applied.
You can run the simplifications manually by opening the Command Palette (Ctrl + Shift + P) and selecting "Source Action". I believe this will be added to the right click menu in the next VS Code release.
This issue is effectively solved for me with the fixAll
action on save, I just wanted to share that finding. If you don't consider it a bug that the formatFlags
option doesn't apply to the "Format Document" command then feel free to close this issue :slightly_smiling_face:
Ok - thanks! The reason it no longer works as part of formatting is that it's now been split out as a code action, as defined in the LSP specification, which is intentional. Closing as result.
What version of Go, VS Code & VS Code Go extension are you using?
go version
to get version of Gogo version go1.14.2 linux/amd64
code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders0.14.1
go env GOOS GOARCH
to get the operating system and processor architecture detailsShare the Go related settings you have added/edited
Describe the bug
Setting
"go.formatFlags": ["-s"],
doesn't work. My code is formatted on save, but the-s
flag is not applied.Steps to reproduce the behavior:
Screenshots or recordings
If applicable, add screenshots or recordings to help explain your problem.