Closed
Description
Proposal
Add p, q = foo!(a, b, c)
notation equivalent to
p, q, err = foo(a, b, c)
if err != nil {
return err
}
to reduce error handling boilerplate code.
This can simplify great amount of code and make it more readable and composable while preserving the full power of idiomatic error handling in Go. For example
func foo(a, b, c int) (*Foo, error) {
p, err := mightFail(a)
if err != nil {
return nil, err
}
q := something(b)
r := somethingElse(c)
return &Foo{p, q, r}, nil
}
becomes
func foo(a, b, c int) (*Foo, error) {
p := mightFail!(a)
q := something(b)
r := somethingElse(c)
return &Foo{p, q, r}, nil
}
or even
func foo(a, b, c int) (*Foo, error) {
return &Foo{mightFail!(a), something(b), somethingElse(c)}, nil
}