diff --git a/common/common.go b/common/common.go index b26ba7704..5ab6a7704 100644 --- a/common/common.go +++ b/common/common.go @@ -11,9 +11,8 @@ func Must(err error) { } } -// Must2 panics if the second parameter is not nil. -func Must2(v interface{}, err error) { - if err != nil { - panic(err) - } +// Must2 panics if the second parameter is not nil, otherwise returns the first parameter. +func Must2(v interface{}, err error) interface{} { + Must(err) + return v }