Documentation
¶
Index ¶
- Variables
- func AddLogWriter(writer io.Writer)
- func Assert(b bool, a ...any)
- func Assertf(b bool, format string, a ...any)
- func Assign[T any](dst *T, src T) T
- func Bind[T any](err error, fn func() (T, error)) (T, error)
- func Bind0(err error, fn func() error) error
- func Bind1[T any](err error, fn func() (T, error)) (T, error)
- func Bind2[T any, U any](err error, fn func() (T, U, error)) (T, U, error)
- func Catch(errRef *error, fns ...func(error))
- func Debugger()
- func E(args ...any) error
- func Elvis[T comparable](t T, f T) T
- func ElvisF[T comparable](t func() T, f func() T) (ret T)
- func Err[T any](err error) (T, error)
- func ErrorAs[T error](err error) (t T)
- func Expect(err error, expectedErrors ...error)
- func Ignore[T any](T, ...any)
- func Let[T any](err error, fn func() T) T
- func Let0(err error, fn func())
- func Let1[T any](err error, fn func() T) T
- func Let2[T any, U any](err error, fn func() (T, U)) (T, U)
- func LogPrint(v ...interface{})
- func LogPrintf(format string, v ...interface{})
- func LogPrintln(v ...interface{})
- func Nil[T any]() (t T)
- func Ok[T any](value T) (T, error)
- func P[T any](v T) *T
- func PMap[T any, U any](pt *T, fn func(*T) *U) *U
- func PR[T any](value T, err error) *valueResult[*T]
- func Ptr[T any](v T) *T
- func PtrMap[T any, U any](pt *T, fn func(*T) *U) *U
- func R[T any](value T, err error) *valueResult[T]
- func RecoverPanicObject[T comparable](errRef *error, target T, fn func() error)
- func RecoverPanicType[T any](errRef *error, fn func(T) error)
- func Ternary[T any](cond bool, t T, f T) T
- func TernaryF[T any](cond bool, t func() T, f func() T) (ret T)
- func TernaryF2[T any, U any](cond bool, t func() (T, U), f func() (T, U)) (ret1 T, ret2 U)
- func Then(err error, fn func() error) error
- func Throw(err error)
- func ThrowIf(err error)
- func V[T any](value T, err error) T
- func V0(args ...any)
- func V2[T any, U any](value1 T, value2 U, err error) (T, U)
- func V3[T any, U any, V any](value1 T, value2 U, value3 V, err error) (T, U, V)
- func WithStack(err error) error
Constants ¶
This section is empty.
Variables ¶
var A = Assert
Functions ¶
func AddLogWriter ¶ added in v0.0.2024072645
func Assertf ¶ added in v0.0.2024073012
Assertf panics with the given message if the condition is false.
func Bind ¶
Bind returns the result of the given function that can fail if err is nil, otherwise the error.
func Debugger ¶ added in v0.0.2024021544
func Debugger()
Debugger waits for a debugger to connect if the environment variable $WAIT_DEBUGGER is set or the first argument is "--wait-debugger"
func Elvis ¶ added in v0.0.2024072420
func Elvis[T comparable](t T, f T) T
Elvis returns the first value if it is not empty, otherwise the second value. // Elvis operator - Wikipedia https://en.wikipedia.org/wiki/Elvis_operator
func ElvisF ¶ added in v0.0.2024072421
func ElvisF[T comparable]( t func() T, f func() T, ) (ret T)
ElvisF returns the result of the first function if it is not empty, otherwise the result of the second function.
func ErrorAs ¶ added in v0.0.2024080520
ErrorAs returns the error as the type T if possible, otherwise returns nil.
func Expect ¶ added in v0.0.2024073012
Expect expects the error to be nil or one of the errors passed as arguments.
func Let0 ¶
func Let0(err error, fn func())
Let0 calls the given function if err is nil and returns nothing.
func LogPrintln ¶ added in v0.0.2024072645
func LogPrintln(v ...interface{})
func RecoverPanicObject ¶
func RecoverPanicObject[T comparable](errRef *error, target T, fn func() error)
func RecoverPanicType ¶
func Ternary ¶
Ternary returns the first value if cond is true, otherwise the second value. // Ternary conditional operator - Wikipedia https://en.wikipedia.org/wiki/Ternary_conditional_operator
func TernaryF ¶
TernaryF returns the result of the first function if cond is true, otherwise the result of the second function.
func TernaryF2 ¶ added in v0.0.2024072004
TernaryF2 returns the result of the first function if cond is true, otherwise the result of the second function.
func V0 ¶ added in v0.0.2024022328
func V0(args ...any)
V0 returns no value. If err is not nil, it panics.
Types ¶
This section is empty.