Closed Codebreaker101 closed 3 years ago
See https://github.com/golang/go/issues/37165 which would work this way.
func AnyError(errs ...error) error {
for _, e := range errs {
if e != nil {
return e
}
}
return nil
}
...
return AnyError(err1, err2, err3)
return AnyError(doSomething1(args), doSomething2(args), doSomething3(args))
It would be greater if lazy evalutaion is supported.
For language change proposals, please fill out the template at https://go.googlesource.com/proposal/+/refs/heads/master/go2-language-changes.md .
When you are done, please reply to the issue with @gopherbot please remove label WaitingForInfo.
Thanks!
See https://github.com/golang/go/issues/40432 for past error handling proposals and associated design problems.
As mentioned above, there are open issues that describes this proposal, in one way or another. Closing this.
Sometimes I have a function that does two or more things and I need to return an error if something failed in the function.
To do that I have to do the following:
Wouldn't it be nice if once can do this insted:
Opinions?