28 lines
359 B
Go
28 lines
359 B
Go
package must
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
)
|
|
|
|
func Do(err error) {
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|
|
|
|
func Get[T any](val T, err error) T {
|
|
Do(err)
|
|
return val
|
|
}
|
|
|
|
func Be(condition bool, msg string, args ...any) {
|
|
if !condition {
|
|
panic(fmt.Errorf(msg, args...)) //nolint:err113 // not a returned error
|
|
}
|
|
}
|
|
|
|
func Close(closer io.Closer) {
|
|
Do(closer.Close())
|
|
}
|