-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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
proposal: gofmt should allow short inlined if-return statements #27135
Comments
Statements that drastically change the program's control flow (like
(which is allowed by |
@ALTree if functions are so big you can't spot a return statement inside an if statement then the issue is with the cleanliness of the code, I think allowing to inline if-return will help reduce the clutter in the eyes. Small functions or even just functions that adhere to Command & Query separation will not have the issue you describe. Thanks for the quick reply! |
I wholeheartedly support this. I never dared to push it because I'm sure it has been discussed before. Just to get the typical pro arguments out there:
|
People forget stuff when there is too much information in the brain short memory any way. Making the code less line can not solve this problem.
The screen is big so you can see two files or three files in vertical parallel. Also note:
|
@bronze1man It seems they are going to solve the clutter issue in go 2 by having a block of error handling, so that might solve the core issue |
See also... |
We decided long ago not to allow this kind of density. If the problem is specifically error handling, then we have other ideas for that (as noted). But the decision that there are no 1-line if statements is done. |
You've seen it everywhere:
Let's allow
if err != nil { return err }
The text was updated successfully, but these errors were encountered: