1 package must 2 3 // Do panics if err is not nil, otherwise returns t. 4 // It is useful in wrapping a two-value function call 5 // where you know statically that the call will succeed. 6 // 7 // Example: 8 // 9 // url := must.Do(url.Parse("http://example.com")) 10 func Do[T any](t T, err error) T { 11 if err != nil { 12 panic(err) 13 } 14 return t 15 } 16