package
Version:
v0.6.14
Opens a new window with list of versions in this module.
Published: Oct 14, 2023
License: MIT
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
Package basefn provide some no-dependents util functions
-
func CallOn(cond bool, fn ErrFunc) error
-
func CallOrElse(cond bool, okFn, elseFn ErrFunc) error
-
func ErrOnFail(cond bool, err error) error
-
func FirstOr[T any](sl []T, elseVal T) T
-
func Must[T any](v T, err error) T
-
func MustOK(err error)
-
func OrError(cond bool, err error) error
-
func OrReturn[T any](cond bool, okFn, elseFn func() T) T
-
func OrValue[T any](cond bool, okVal, elVal T) T
-
func PanicErr(err error)
-
func PanicIf(cond bool, fmtAndArgs ...any)
-
func Panicf(format string, v ...any)
-
type ErrFunc
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
func FirstOr[T any](sl []T, elseVal T) T
FirstOr get first elem or elseVal
Must if error is not empty, will panic
MustOK if error is not empty, will panic
OrError return input error on cond is false, otherwise return nil
func OrReturn[T any](cond bool, okFn, elseFn func() T) T
OrReturn call okFunc() on condition is true, else call elseFn()
func OrValue[T any](cond bool, okVal, elVal T) T
OrValue get
PanicErr panics if error is not empty
func PanicIf(cond bool, fmtAndArgs ...any)
PanicIf if cond = true, panics with error message
Panicf format panic message use fmt.Sprintf
type ErrFunc func() error
ErrFunc type
Source Files
¶
Click to show internal directories.
Click to hide internal directories.