refactor: migrate 'flowutils' to 'must' helpers
This commit is contained in:
27
pkg/must/must.go
Normal file
27
pkg/must/must.go
Normal file
@@ -0,0 +1,27 @@
|
||||
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())
|
||||
}
|
||||
Reference in New Issue
Block a user