Documentation
¶
Index ¶
- func CallerInfo(skip int, adjust ...int) (file string, line int, pkg, fname string)
- func Error(args ...any) error
- func ErrorFrom[T any](t T, err error) error
- func ErrorFrom2[T, U any](t T, u U, err error) error
- func ErrorFrom3[T, U, V any](t T, u U, v V, err error) error
- func First[T any](v T, rest ...any) T
- func Fourth[T any](a, b, c any, v T, rest ...any) T
- func Last[T any](args ...any) T
- func Must[T any](o T, err error) T
- func Second[T any](a any, v T, rest ...any) T
- func Third[T any](a, b any, v T, rest ...any) T
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallerInfo ¶
func Error ¶
Error provides the last value, which must be of type error. It is expected to be called on the result of a function call providing an error return, whose results should be ignored beside the provided error. e.g.: Error(f())
func ErrorFrom2 ¶
func ErrorFrom3 ¶
Types ¶
type Option ¶
type Option[T any] interface { // IsNone indicates whether a value is provided or not. IsNone() bool // Value provides the value of an Option. // If no value is provided, a panic is called. // It may only be called if IsNone() is false. Value() T // Error provides an error is IsNone is false. Error() error }
Option represents an optional resuölt of a function. If can represent a result value (of type T) or no result value potentially with an error.
func AndThen ¶
AndThen chains an operation on a given Option result, for example, if f and g are two operations providing an optional result the AndThen(f(), g) provides a result if f and g provide a result, whereas g is only called and fed with the result of f if f provided a result. Option together with AndThen enables chaining of function calls providing Nil results or error results.