blob: ff06f8c17d8d52981384eb8bb5866bb0728ca3b9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
|
//go:build go1.18
package errors
// Must is a generic helper, like template.Must, that wraps a call to a function returning (T, error)
// and panics if the error is non-nil.
func Must[T any](val T, err error) T {
if err != nil {
panic(err)
}
return val
}
|