-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: implicit if err != nil { return err } #56355
Comments
You still can continue to write if err != nil { ... } but |
Please note that you should fill https://github.com/golang/proposal/blob/master/go2-language-changes.md when proposing a language change. |
I'm not sure I understand what |
Well yes, it is similar., but the good thing about using a What I don't like about seeing
Personally, I like the way it is easy to see where errors can be returned(i, _ := something...), but it can be as clear by using a |
@mvdan Got it, should I edit the existing one or close it and open a new one ? |
Duplicate of #42214 |
@seankhliao Sorry but I don't agree. My proposition is way less invasive. #42214 is proposing built-in function. I won't vote for this complexity. I'm proposing a global constant like It is more rigid and have the only purpose to replace the I'm currently writing some generic utility function and I'm constantly using this |
Having a global constant like
_
to do a non-D.R.Y. job.?
can be a global constant of typeerror
and when assign a non-nil value exit the function/method returning all zero values except theerror
which is the value assign to?
.Here an example using
?
as a global constant for the most, and by far, repeated code in Go.The text was updated successfully, but these errors were encountered: