-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
FrozenDueToAgeLanguageChangeSuggested changes to the Go languageSuggested changes to the Go languageProposalerror-handlingLanguage & library change proposals that are about error handling.Language & library change proposals that are about error handling.v2An incompatible library changeAn incompatible library change
Milestone
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.
pjebs, rasky, dpinela, mikeschinkel and rvillablancatmthrgd, reusee, deanveloper, gregory-m, choleraehyq and 2 more
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeLanguageChangeSuggested changes to the Go languageSuggested changes to the Go languageProposalerror-handlingLanguage & library change proposals that are about error handling.Language & library change proposals that are about error handling.v2An incompatible library changeAn incompatible library change