Must returns v if err is nil and panics otherwise.
(v T, err error)
| 59 | |
| 60 | // Must returns v if err is nil and panics otherwise. |
| 61 | func Must[T any](v T, err error) T { |
| 62 | if err != nil { |
| 63 | panic(fmt.Sprintf("Must received error: %v", FormatError(err))) |
| 64 | } |
| 65 | return v |
| 66 | } |
| 67 | |
| 68 | // WaitTimeout returns true if f returns after at most d or false otherwise. |
| 69 | // An example of a f, for which this is useful would be Wait method of sync.WaitGroup. |