common

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BatchOrFail added in v0.4.0

func BatchOrFail[T any](size uint32, in iter.Seq2[T, error]) iter.Seq2[[]T, error]

func Collect added in v0.4.0

func Collect[T any](in iter.Seq[T]) []T

func CollectOrFail added in v0.4.0

func CollectOrFail[T any](in iter.Seq2[T, error]) ([]T, error)

func DoIfFalse added in v0.3.0

func DoIfFalse(assertToBeTrue *bool, otherwise func())

func IgnoreCloseError

func IgnoreCloseError(when io.Closer)

func IgnoreCloseErrorIfFalse added in v0.3.0

func IgnoreCloseErrorIfFalse(assertToBeTrue *bool, otherwise io.Closer)

func IgnoreError

func IgnoreError(when func() error)

func IgnoreErrorIfFalse added in v0.3.0

func IgnoreErrorIfFalse(assertToBeTrue *bool, otherwise func() error)

func JoinSeq added in v0.3.0

func JoinSeq[T any](seqs ...iter.Seq[T]) iter.Seq[T]

func JoinSeq2 added in v0.3.0

func JoinSeq2[K any, V any](seqs ...iter.Seq2[K, V]) iter.Seq2[K, V]

func KeepCloseError

func KeepCloseError(target *error, when io.Closer)

func KeepError

func KeepError(target *error, when func() error)

func MapSlice

func MapSlice[I any, O any](in []I, mapper func(I) O) []O

func MapSliceErr

func MapSliceErr[I any, O any](in []I, mapper func(I) (O, error)) ([]O, error)

func Must

func Must(v error, msgAndArgs ...any)

func MustNotNil

func MustNotNil(v any, msgAndArgs ...any)

func P

func P[T any](a T) *T

func Seq2ErrOf added in v0.3.0

func Seq2ErrOf[T any](ts ...T) iter.Seq2[T, error]

func Seq2Of added in v0.3.0

func Seq2Of[K any, V any](kvs ...KV[K, V]) iter.Seq2[K, V]

func SeqOf added in v0.3.0

func SeqOf[T any](ts ...T) iter.Seq[T]

func SingleSeq2Of added in v0.3.0

func SingleSeq2Of[K any, V any](k K, v V) iter.Seq2[K, V]

func SingleSeqOf added in v0.3.0

func SingleSeqOf[T any](t T) iter.Seq[T]

func Sleep added in v0.5.8

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

func SleepSilently added in v0.5.8

func SleepSilently(ctx context.Context, duration time.Duration)

func ToDebugString

func ToDebugString(formatted bool, what any) string

Types

type Duration

type Duration struct {
	// contains filtered or unexported fields
}

func DurationOf

func DurationOf(native time.Duration) Duration

func MustNewDuration

func MustNewDuration(plain string) Duration

func NewDuration

func NewDuration(plain string) (Duration, error)

func (Duration) IsEqualTo

func (this Duration) IsEqualTo(other any) bool

func (Duration) IsZero

func (this Duration) IsZero() bool

func (Duration) MarshalText

func (this Duration) MarshalText() (text []byte, err error)

func (*Duration) Native

func (this *Duration) Native() time.Duration

func (*Duration) Set

func (this *Duration) Set(text string) error

func (*Duration) SetNative

func (this *Duration) SetNative(v time.Duration)

func (Duration) String

func (this Duration) String() string

func (*Duration) UnmarshalText

func (this *Duration) UnmarshalText(text []byte) error

func (*Duration) Validate added in v0.4.0

func (this *Duration) Validate() error

type KV added in v0.3.0

type KV[K any, V any] struct {
	K K
	V V
}

type KeyedMutex added in v0.4.0

type KeyedMutex[K comparable] struct {
	// contains filtered or unexported fields
}

func (*KeyedMutex[K]) Lock added in v0.4.0

func (this *KeyedMutex[K]) Lock(key K) Unlocker

func (*KeyedMutex[K]) RLock added in v0.4.0

func (this *KeyedMutex[K]) RLock(key K) Unlocker

type Regexp

type Regexp struct {
	// contains filtered or unexported fields
}

func MustNewRegexp

func MustNewRegexp(plain string) Regexp

func NewRegexp

func NewRegexp(plain string) (Regexp, error)

func (Regexp) IsEqualTo

func (this Regexp) IsEqualTo(other any) bool

func (Regexp) IsZero

func (this Regexp) IsZero() bool

func (Regexp) MarshalText

func (this Regexp) MarshalText() (text []byte, err error)

func (*Regexp) MatchString

func (this *Regexp) MatchString(s string) bool

func (*Regexp) Set

func (this *Regexp) Set(text string) error

func (Regexp) String

func (this Regexp) String() string

func (*Regexp) UnmarshalText

func (this *Regexp) UnmarshalText(text []byte) error

func (Regexp) Validate added in v0.4.0

func (this Regexp) Validate() error

type StructuredKey

type StructuredKey []string

func StructuredKeyOf

func StructuredKeyOf(args ...string) StructuredKey

func (StructuredKey) Child

func (this StructuredKey) Child(key string) StructuredKey

func (StructuredKey) Index

func (this StructuredKey) Index(i int) StructuredKey

func (StructuredKey) String

func (this StructuredKey) String() string

type Unlocker added in v0.4.0

type Unlocker func()

Jump to

Keyboard shortcuts

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