types

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CastFloat added in v1.5.0

func CastFloat[T, V constraints.Float](v V) T

func CastInteger added in v1.5.0

func CastInteger[T, V constraints.Integer](v V) T

func CastNumber added in v1.5.0

func CastNumber[T, V constraintsi.Number](v V) T

func CastSigned added in v1.5.0

func CastSigned[T, V constraints.Signed](v V) T

func CastUnsigned added in v1.5.0

func CastUnsigned[T, V constraints.Unsigned](v V) T

func Equal added in v1.5.0

func Equal[T constraints.Ordered](a T, b T) bool

func Greater added in v1.5.0

func Greater[T constraints.Ordered](a T, b T) bool

func Less added in v1.5.0

func Less[T constraints.Ordered](a T, b T) bool

func TernaryOp added in v1.5.0

func TernaryOp[T any](yes bool, a, b T) T

func Zero added in v1.5.0

func Zero[T any]() T

func Zero2 added in v1.5.0

func Zero2[T any]() T

Types

type Basic

type Basic struct {
}

type Bool

type Bool int8

func (Bool) IsFalse

func (b Bool) IsFalse() bool

func (Bool) IsNone

func (b Bool) IsNone() bool

func (Bool) IsTrue

func (b Bool) IsTrue() bool

func (Bool) MarshalBinary

func (b Bool) MarshalBinary() ([]byte, error)

MarshalBinary

func (Bool) MarshalJSON

func (b Bool) MarshalJSON() ([]byte, error)

func (Bool) MarshalText

func (b Bool) MarshalText() ([]byte, error)

MarshalText

func (Bool) String

func (b Bool) String() string

String implements Stringer.

func (*Bool) UnmarshalBinary

func (b *Bool) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (*Bool) UnmarshalJSON

func (b *Bool) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Bool) UnmarshalText

func (b *Bool) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type Dict

type Dict[K comparable, V any] struct {
	Key   K
	Value V
}

type Enum

type Enum[T constraints.Unsigned | ~string] struct {
	Value T
}

type FCompare added in v1.5.0

type FCompare[T any] func(T, T) bool

type FCompareByIndex added in v1.5.0

type FCompareByIndex func(i, j int) bool

type FGrpcServiceMethod added in v1.5.0

type FGrpcServiceMethod[REQ, RES any] func(context.Context, REQ) (RES, error)

type FTask added in v1.5.0

type FTask func(context.Context)

type FTaskWithErr added in v1.5.0

type FTaskWithErr func(context.Context) error

type Func

type Func func()

type FuncWithErr

type FuncWithErr func() error

type GTValue

type GTValue[T constraints.Ordered] struct {
	Value T
}

func (GTValue[T]) Compare

func (a GTValue[T]) Compare(b GTValue[T]) bool

type ICompare

type ICompare[T any] interface {
	Compare(T) bool
}

type ICompareKey added in v1.5.0

type ICompareKey[T comparable] interface {
	CompareKey() T
}

type ID

type ID[T constraintsi.ID] struct {
	Id T `json:"id"`
}

type IDelete

type IDelete[K constraints.Key, V any] interface {
	Delete(key K)
}

type IDurationGenerator

type IDurationGenerator interface {
	Duration() time.Duration
}

type IGet

type IGet[K constraints.Key, V any] interface {
	Get(key K) V
}

type IIdGenerator

type IIdGenerator[T constraints.ID] interface {
	Id() T
}

type IInit

type IInit interface {
	Init()
}

type IKey

type IKey[T constraints.Key] interface {
	Key() T
}

type ISet

type ISet[K constraints.Key, V any] interface {
	Set(key K, v V)
}

type ISetWithExpire added in v1.5.0

type ISetWithExpire[K constraints.Key, V any] interface {
	SetWithExpire(key K, v V, expire time.Duration)
}

type IStore added in v1.5.0

type IStore[K constraints.Key, V any] interface {
	ISet[K, V]
	IGet[K, V]
	IDelete[K, V]
}

type IStoreWithExpire added in v1.5.0

type IStoreWithExpire[K constraints.Key, V any] interface {
	ISetWithExpire[K, V]
	IGet[K, V]
	IDelete[K, V]
}

type Int

type Int int

func (Int) Key

func (s Int) Key() int

type LTValue

type LTValue[T constraints.Ordered] struct {
	Value T
}

func (LTValue[T]) Compare

func (a LTValue[T]) Compare(b GTValue[T]) bool

type Option

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

func MapOption

func MapOption[T any, R any](opt *Option[T], fn func(T) R) *Option[R]

func Nil

func Nil[T any]() *Option[T]

func None

func None[T any]() *Option[T]

func Some

func Some[T any](v T) *Option[T]

func (*Option[T]) Get

func (opt *Option[T]) Get() (T, bool)

func (*Option[T]) IfNone

func (a *Option[T]) IfNone(action func())

func (*Option[T]) IfSome

func (a *Option[T]) IfSome(action func(value T))

func (*Option[T]) IsNone

func (opt *Option[T]) IsNone() bool

func (*Option[T]) IsSome

func (opt *Option[T]) IsSome() bool

func (*Option[T]) MarshalJSON

func (a *Option[T]) MarshalJSON() ([]byte, error)

func (*Option[T]) Next

func (a *Option[T]) Next() *Option[T]

func (*Option[T]) UnmarshalJSON

func (a *Option[T]) UnmarshalJSON(data []byte) error

func (*Option[T]) Unwrap

func (opt *Option[T]) Unwrap() T

func (*Option[T]) UnwrapOr

func (opt *Option[T]) UnwrapOr(def T) T

func (*Option[T]) UnwrapOrElse

func (opt *Option[T]) UnwrapOrElse(fn func() T) T

func (*Option[T]) Val

func (opt *Option[T]) Val() (T, bool)

type Pair

type Pair[T1 any, T2 any] struct {
	First  T1
	Second T2
}

func PairOf

func PairOf[T1 any, T2 any](f T1, s T2) *Pair[T1, T2]

func (*Pair[T1, T2]) Val

func (a *Pair[T1, T2]) Val() (T1, T2)

type Ref

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

func RefOf

func RefOf[T any](v *T) Ref[T]

func (Ref[T]) Get

func (a Ref[T]) Get() T

func (Ref[T]) IsNil

func (a Ref[T]) IsNil() bool

func (Ref[T]) IsNotNil

func (a Ref[T]) IsNotNil() bool

func (Ref[T]) Set

func (a Ref[T]) Set(v T) T

func (Ref[T]) Val

func (a Ref[T]) Val() (v T, ok bool)

type Result

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

func Err

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

func Ok

func Ok[T any](a T) Result[T]

func (Result[T]) IfErr

func (a Result[T]) IfErr(action func(err error))

func (Result[T]) IfOk

func (a Result[T]) IfOk(action func(value T))

func (Result[T]) IsErr

func (a Result[T]) IsErr() bool

func (Result[T]) IsErrAnd

func (a Result[T]) IsErrAnd(f func(error) bool) bool

func (Result[T]) IsOk

func (a Result[T]) IsOk() bool

func (Result[T]) IsOkAnd

func (a Result[T]) IsOkAnd(f func(T) bool) bool

func (*Result[T]) MarshalJSON

func (a *Result[T]) MarshalJSON() ([]byte, error)

func (Result[T]) Or

func (a Result[T]) Or(value T) T

func (Result[T]) OrDefault

func (a Result[T]) OrDefault() (v T)

func (Result[T]) OrPanic

func (a Result[T]) OrPanic() T

func (*Result[T]) UnmarshalJSON

func (a *Result[T]) UnmarshalJSON(data []byte) error

func (Result[T]) Val

func (a Result[T]) Val() (value T, err error)

type String

type String string

func (String) Key

func (s String) Key() string

type Tuple

type Tuple[T1 any, T2 any, T3 any] struct {
	First  T1
	Second T2
	Third  T3
}

func TupleOf

func TupleOf[T1 any, T2 any, T3 any](f T1, s T2, t T3) *Tuple[T1, T2, T3]

func (*Tuple[T1, T2, T3]) Val

func (a *Tuple[T1, T2, T3]) Val() (T1, T2, T3)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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