Documentation
¶
Index ¶
- func AllOfProvided2[T1, T2 any](f1 func() (T1, error), f2 func() (T2, error)) (t1 T1, t2 T2, err error)
- func AllOfProvided3[T1, T2, T3 any](f1 func() (T1, error), f2 func() (T2, error), f3 func() (T3, error)) (t1 T1, t2 T2, t3 T3, err error)
- func AllOfProvided4[T1, T2, T3, T4 any](f1 func() (T1, error), f2 func() (T2, error), f3 func() (T3, error), ...) (t1 T1, t2 T2, t3 T3, t4 T4, err error)
- func AllOfProvided5[T1, T2, T3, T4, T5 any](f1 func() (T1, error), f2 func() (T2, error), f3 func() (T3, error), ...) (t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, err error)
- func If[T any](condition bool, a T, b T) T
- func Must[T any](t T, err error) T
- func Or[T comparable](candidates ...T) (out T)
- func OrProvide[T comparable](t T, provide func() T) (out T)
- func OrUnref[T any](v *T, def T) T
- func Ref[T any](t T) *T
- func Todo[a any]() a
- func Todoe[a any]() (val a, err error)
- func Try(f func() error) (err error)
- type ErrTodo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllOfProvided2 ¶ added in v1.6.0
func AllOfProvided2[T1, T2 any](f1 func() (T1, error), f2 func() (T2, error)) (t1 T1, t2 T2, err error)
AllOfProvided2 calls each provider in order, returning early on the first nil provider or the first error. On success all return values are populated.
func AllOfProvided3 ¶ added in v1.6.0
func AllOfProvided3[T1, T2, T3 any](f1 func() (T1, error), f2 func() (T2, error), f3 func() (T3, error)) (t1 T1, t2 T2, t3 T3, err error)
AllOfProvided3 calls each provider in order, returning early on the first nil provider or the first error. On success all return values are populated.
func AllOfProvided4 ¶ added in v1.6.0
func AllOfProvided4[T1, T2, T3, T4 any](f1 func() (T1, error), f2 func() (T2, error), f3 func() (T3, error), f4 func() (T4, error)) (t1 T1, t2 T2, t3 T3, t4 T4, err error)
AllOfProvided4 calls each provider in order, returning early on the first nil provider or the first error. On success all return values are populated.
func AllOfProvided5 ¶ added in v1.6.0
func AllOfProvided5[T1, T2, T3, T4, T5 any](f1 func() (T1, error), f2 func() (T2, error), f3 func() (T3, error), f4 func() (T4, error), f5 func() (T5, error)) (t1 T1, t2 T2, t3 T3, t4 T4, t5 T5, err error)
AllOfProvided5 calls each provider in order, returning early on the first nil provider or the first error. On success all return values are populated.
func Must ¶
Must takes tuple of value with error and returns only value if error is nil. If error not nil - panics it.
func Or ¶
func Or[T comparable](candidates ...T) (out T)
Or returns first not-default value among all given candidates. If candidates slice is empty it returns default value for T.
func OrProvide ¶ added in v1.6.0
func OrProvide[T comparable](t T, provide func() T) (out T)
OrProvide returns t if it is not the zero value for T, otherwise it calls provide and returns its result.
func OrUnref ¶ added in v1.5.2
func OrUnref[T any](v *T, def T) T
OrUnref returns value of first argument if it's not nil otherwise returns second argument.
func Todo ¶ added in v1.5.0
func Todo[a any]() a
Todo is a temporary stubber function to use for places when some value/component is expected but yet not implemented. Any invocation of this function will produce panic.