-
Notifications
You must be signed in to change notification settings - Fork 17.4k
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: Complete return as a snippet #64266
Comments
Note there is some logic to write a "return" snippet with zero values here. This proposed completion could work in a similar way to that linked completion. |
Thanks @muirdm that is a great point! This proposal would be a subset of that functionality. I'll see if I can make it fit together nicely. |
Change https://go.dev/cl/546775 mentions this issue: |
This was fixed by https://go.dev/cl/546775 (the commit message said "Closes" instead of "Fixes"). |
Hi, I'm sorry for commenting so late. If "err" exists, should it be used first to instead "nil"? I think this is more common. |
Hi @rogeryk That is a valid point. I decided against it, keeping the zero value even for the error, to keep the implementation simple. The end user might want err, fmt.Errorf, errors.New, or some local variant thereof (which is what I almost always use). My reasoning was that since the placeholder almost surely needs to be replaced anyway, it doesn't hurt that it is nil. |
Feature suggestion
It would be convenient if the return keyword could be completed as a snippet that pre-populates the zero values of return parameters.
For example
would turn into
with the snippet cursor over "" and nil respectively.
Currently the keyword is only completed to a plain
return
. This could be an alternative completion ranked one step lower.The text was updated successfully, but these errors were encountered: