Back to Lo

Core Mustx

docs/data/core-mustx.md

1.53.0417 B
Original Source

Panics if err is an error or false, returning successful values otherwise. Variants cover functions returning 0 to 6 values.

go
// returns 10, panics if err is not nil
v := lo.Must(strconv.Atoi("10"))

// panics with custom message
lo.Must0(fmt.Errorf("boom"), "failed to parse")

// panics if myFunc returns an error
func myFunc() (int, string, float64, bool, error) { ... }
a, b, c, d := lo.Must4(myFunc())