Skip to content
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: add quick fixes that behave like goreturns #37091

Closed
stamblerre opened this issue Feb 6, 2020 · 3 comments
Closed

x/tools/gopls: add quick fixes that behave like goreturns #37091

stamblerre opened this issue Feb 6, 2020 · 3 comments
Labels
FeatureRequest FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@stamblerre
Copy link
Contributor

stamblerre commented Feb 6, 2020

A main reason that users are still not using gopls for formatting is that they prefer to use goreturns, which combines goimports, gofmt, and also fills in default values for function returns, if they are left blank. We could add that same behavior as a quick-fix suggestion that gets offered as part of textDocument/codeAction.

@stamblerre stamblerre added this to the gopls/v1.0.0 milestone Feb 6, 2020
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Feb 6, 2020
@ridersofrohan ridersofrohan self-assigned this Feb 28, 2020
@thepudds
Copy link
Contributor

thepudds commented Mar 4, 2020

Hello @stamblerre and @ridersofrohan, is expanderr functionality still being considered for gopls? It seem like it had been close based on the initial CL from @stapelberg that @stamblerre then took over:

https://go-review.googlesource.com/c/tools/+/188637

I think goreturns might be more well-known, but at least in my personal opinion I think expanderr might be better (with “better” of course being subjective).

From the expanderr README:

How does expanderr differ from goreturns?

goreturns only inserts a return statement with zero values for the current function.

expanderr understands the signature of the call expression under your cursor and inserts the appropriate error checking statement (including a return statement). In practice, this eliminates the need of combining goreturns with an editor snippet, with the additional bonus of working correctly in a larger number of situations.

@stamblerre
Copy link
Contributor Author

The reasoning behind goreturns is because VS Code Go supports it as a formatter option, and we wanted to make sure that we had feature parity with that first. I don't have the time to continue with the expanderr work, but I could certainly see that as being a follow-up to this issue.

@stamblerre stamblerre modified the milestones: gopls/v1.0.0, Unreleased Mar 12, 2020
@golang golang deleted a comment from gopherbot Mar 27, 2020
@golang golang deleted a comment from gopherbot Mar 27, 2020
@gopherbot
Copy link

Change https://golang.org/cl/224960 mentions this issue: internal/lsp: add goreturns like functionality as quickfix

@golang golang locked and limited conversation to collaborators Apr 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants