fak

package module
v0.0.0-...-fe04427 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 9 Imported by: 2

README

GOPROXY=direct go get -u github.com/itsabgr/fak

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAssertionFailed = errors.New("assertion failed")

Functions

func Assert

func Assert(cond bool, err error)

func Async

func Async[R any](ctx context.Context, fn func() R) (R, error)

func CastInterfaces

func CastInterfaces[T any, T2 any](slice ...T) []T2

func Chan

func Chan[R any](fn func() R) <-chan R

func ConcatErrors

func ConcatErrors(errs ...error) string

func Flush

func Flush[T any](c <-chan T) (i int)

func LockContext

func LockContext(ctx context.Context, lock interface{ TryLock() bool }) error

func Must

func Must[T any](res T, err any) T

func Or

func Or[T comparable](vals ...T) (t T)

func Ptr

func Ptr[T any](t T) *T

func ReadAll

func ReadAll(ctx context.Context, r io.Reader, b []byte) ([]byte, error)

func SignalContext

func SignalContext(ctx context.Context, signals ...os.Signal) context.Context

func Sleep

func Sleep(ctx context.Context, duration time.Duration) error

func Slice

func Slice[T ~[]E, E any](list T, start, end int) T

func Throw

func Throw(err any)

func Timeout

func Timeout[T any](ctx context.Context, timeout time.Duration, fn func(timeoutCtx context.Context) (T, error)) (T, error)

func Try

func Try[T any](panicableFunc func() T) (res T, err any)

func UnwrapAll

func UnwrapAll(err error) []error

func Variadic

func Variadic[T any](elems ...T) []T

func Wrap

func Wrap(wrapper, original error) error

func Zero

func Zero[T any]() (z T)

Types

type Result

type Result[T any] struct {
	// contains filtered or unexported fields
}

func Err

func Err[T any](err error) Result[T]

func OK

func OK[T any](res T) Result[T]

func (Result[T]) Err

func (r Result[T]) Err() error

func (Result[T]) Must

func (r Result[T]) Must() T

func (Result[T]) Result

func (r Result[T]) Result() (T, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL