package basefn

Import Path
	github.com/gookit/goutil/x/basefn (on go.dev)

Dependency Relation
	imports 3 packages, and imported by one package

Involved Source Files Package basefn provide some no-dependents util functions
Package-Level Type Names (only one)
/* sort by: | */
ErrFunc type func CallOn(cond bool, fn ErrFunc) error func CallOrElse(cond bool, okFn, elseFn ErrFunc) error
Package-Level Functions (total 13)
CallOn call func on condition is true
CallOrElse call okFunc() on condition is true, else call elseFn()
ErrOnFail return input error on cond is false, otherwise return nil
Type Parameters: T: any FirstOr get first elem or elseVal
Type Parameters: T: any Must return like (v, error). will panic on error, otherwise return v. Usage: // old v, err := fn() if err != nil { panic(err) } // new v := goutil.Must(fn())
MustIgnore for return like (v, error). Ignore return v and will panic on error. Useful for io, file operation func: (n int, err error) Usage: // old _, err := fn() if err != nil { panic(err) } // new basefn.MustIgnore(fn())
MustOK if error is not empty, will panic
OrError return input error on cond is false, otherwise return nil
Type Parameters: T: any OrReturn call okFunc() on condition is true, else call elseFn() like expr: if cond { okFunc() } else { elseFn() }
Type Parameters: T: any OrValue get. like: if cond { okVal } else { elVal }
PanicErr panics if error is not empty
Panicf format panic message use fmt.Sprintf
PanicIf if cond = true, panics with an error message