v0.0.379
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m57s
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 2m57s
This commit is contained in:
21
langext/must.go
Normal file
21
langext/must.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package langext
|
||||
|
||||
// Must returns a value and panics on error
|
||||
//
|
||||
// Usage: Must(methodWithError(...))
|
||||
func Must[T any](v T, err error) T {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// MustBool returns a value and panics on missing
|
||||
//
|
||||
// Usage: MustBool(methodWithOkayReturn(...))
|
||||
func MustBool[T any](v T, ok bool) T {
|
||||
if !ok {
|
||||
panic("not ok")
|
||||
}
|
||||
return v
|
||||
}
|
Reference in New Issue
Block a user