Closed
Description
It would be great if there was a generic must
function in "builtin" package.
It would be equivalent to this:
eg.
Say we have an arbitrary function that looks like this:
x, y, z, err := function()
x, y, z is of arbitrary type T1, T2, T3 respectively.
the proposed must( function() )
function will return x of type T1 if err == nil
and panic(err) if err != nil
The function is better suited for functions which return 2 values, the last of which is type error
. But it can be generalized to any number of return values provided the final return value is of type error.