utils

package
v1.18.9 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2024 License: GPL-3.0 Imports: 16 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UnsafeRandReader = unsafeRandReader{}
View Source
var UnsafeUUIDGenerator = uuid.NewGenWithOptions(uuid.WithRandomReader(UnsafeRandReader))

Functions

func EmptyOr

func EmptyOr[T comparable](v T, def T) T

func Filter

func Filter[T comparable](tSlice []T, filter func(t T) bool) []T

func GlobalID

func GlobalID(material string) (id [8]byte)

func ImmutableBytesFromString

func ImmutableBytesFromString(s string) []byte

ImmutableBytesFromString is equivalent to []byte(s), except that it uses the same memory backing s instead of making a heap-allocated copy. This is only valid if the returned slice is never mutated.

func MapHash

func MapHash(material string) uint64

func MustOK

func MustOK[T any](result T, ok bool) T

func NewUUIDV1

func NewUUIDV1() uuid.UUID

func NewUUIDV3

func NewUUIDV3(ns uuid.UUID, name string) uuid.UUID

func NewUUIDV4

func NewUUIDV4() uuid.UUID

func NewUUIDV5

func NewUUIDV5(ns uuid.UUID, name string) uuid.UUID

func NewUUIDV6

func NewUUIDV6() uuid.UUID

func NewUUIDV7

func NewUUIDV7() uuid.UUID

func Reverse

func Reverse(s string) string

func StringFromImmutableBytes

func StringFromImmutableBytes(bs []byte) string

StringFromImmutableBytes is equivalent to string(bs), except that it uses the same memory backing bs instead of making a heap-allocated copy. This is only valid if bs is never mutated after StringFromImmutableBytes returns.

func ToStringSlice

func ToStringSlice(value any) ([]string, error)

Types

type Callback added in v1.18.6

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

func NewCallback added in v1.18.6

func NewCallback[T any]() *Callback[T]

func (*Callback[T]) Emit added in v1.18.6

func (c *Callback[T]) Emit(item T)

func (*Callback[T]) Register added in v1.18.6

func (c *Callback[T]) Register(item func(T)) io.Closer

type HashType added in v1.18.9

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

HashType warps hash array inside struct someday can change to other hash algorithm simply

func MakeHash added in v1.18.9

func MakeHash(data []byte) HashType

func (HashType) Bytes added in v1.18.9

func (h HashType) Bytes() []byte

func (HashType) Equal added in v1.18.9

func (h HashType) Equal(hash HashType) bool

func (HashType) IsValid added in v1.18.9

func (h HashType) IsValid() bool

func (HashType) Len added in v1.18.9

func (h HashType) Len() int

func (HashType) MarshalBinary added in v1.18.9

func (h HashType) MarshalBinary() ([]byte, error)

func (HashType) MarshalText added in v1.18.9

func (h HashType) MarshalText() ([]byte, error)

func (HashType) String added in v1.18.9

func (h HashType) String() string

func (*HashType) UnmarshalBinary added in v1.18.9

func (h *HashType) UnmarshalBinary(data []byte) error

func (*HashType) UnmarshalText added in v1.18.9

func (h *HashType) UnmarshalText(data []byte) error

type IntRanges

type IntRanges[T constraints.Integer] []Range[T]

func NewSignedRanges added in v1.18.1

func NewSignedRanges[T constraints.Signed](expected string) (IntRanges[T], error)

func NewSignedRangesFromList added in v1.18.1

func NewSignedRangesFromList[T constraints.Signed](list []string) (IntRanges[T], error)

func NewUnsignedRanges added in v1.18.1

func NewUnsignedRanges[T constraints.Unsigned](expected string) (IntRanges[T], error)

func NewUnsignedRangesFromList added in v1.18.1

func NewUnsignedRangesFromList[T constraints.Unsigned](list []string) (IntRanges[T], error)

func (IntRanges[T]) Check

func (ranges IntRanges[T]) Check(status T) bool

func (IntRanges[T]) Range added in v1.18.2

func (ranges IntRanges[T]) Range(f func(t T) bool)

func (IntRanges[T]) String added in v1.18.2

func (ranges IntRanges[T]) String() string

type Range

type Range[T constraints.Ordered] struct {
	// contains filtered or unexported fields
}

func NewRange

func NewRange[T constraints.Ordered](start, end T) Range[T]

func (Range[T]) Contains

func (r Range[T]) Contains(t T) bool

func (Range[T]) End

func (r Range[T]) End() T

func (Range[T]) LeftContains

func (r Range[T]) LeftContains(t T) bool

func (Range[T]) RightContains

func (r Range[T]) RightContains(t T) bool

func (Range[T]) Start

func (r Range[T]) Start() T

Jump to

Keyboard shortcuts

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