common

package
v0.5.0-alpha.9 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: GPL-2.0 Imports: 10 Imported by: 693

Documentation

Index

Constants

View Source
const LowMemory = false

Variables

View Source
var (
	ContextWithCancelCause = context.WithCancelCause
	ContextCause           = context.Cause
)
View Source
var NativeEndian = binary.NativeEndian

Functions

func All

func All[T any](array []T, block func(it T) bool) bool

func AllIndexed

func AllIndexed[T any](array []T, block func(index int, it T) bool) bool

func Any

func Any[T any](array []T, block func(it T) bool) bool

func AnyError deprecated

func AnyError(errs ...error) error

Deprecated: use E.Errors

func AnyIndexed

func AnyIndexed[T any](array []T, block func(index int, it T) bool) bool

func Cast

func Cast[T any](obj any) (T, bool)

func ClearArray added in v0.3.0

func ClearArray[T ~[]E, E any](t T)

func ClearMap added in v0.3.0

func ClearMap[T ~map[K]V, K comparable, V any](t T)

func Close

func Close(closers ...any) error

func Closer

func Closer(closer func() error) io.Closer

func Contains

func Contains[T comparable](arr []T, target T) bool

func DefaultValue

func DefaultValue[T any]() T

func Done

func Done(ctx context.Context) bool

func Dup

func Dup[T any](obj T) T

func Error

func Error(_ any, err error) error

func Filter

func Filter[T any](arr []T, block func(it T) bool) []T

func FilterIndexed

func FilterIndexed[T any](arr []T, block func(index int, it T) bool) []T

func FilterIsInstance

func FilterIsInstance[T any, N any](arr []T, block func(it T) (N, bool)) []N

func FilterNotDefault

func FilterNotDefault[T comparable](arr []T) []T

func FilterNotNil

func FilterNotNil[T any](arr []T) []T

func Find

func Find[T any](arr []T, block func(it T) bool) T

func FindIndexed added in v0.2.5

func FindIndexed[T any](arr []T, block func(index int, it T) bool) T

func FlatMap

func FlatMap[T any, N any](arr []T, block func(it T) []N) []N

func FlatMapIndexed

func FlatMapIndexed[T any, N any](arr []T, block func(index int, it T) []N) []N

func Index added in v0.2.5

func Index[T any](arr []T, block func(it T) bool) int

func IndexIndexed added in v0.2.5

func IndexIndexed[T any](arr []T, block func(index int, it T) bool) int

func IsEmpty

func IsEmpty[T comparable](obj T) bool

func KeepAlive

func KeepAlive(obj any)

func Map

func Map[T any, N any](arr []T, block func(it T) N) []N

func MapIndexed

func MapIndexed[T any, N any](arr []T, block func(index int, it T) N) []N

func MaxBy

func MaxBy[T any, C constraints.Ordered](arr []T, block func(it T) C) T

func MinBy

func MinBy[T any, C constraints.Ordered](arr []T, block func(it T) C) T

func Must

func Must(errs ...error)

func Must1

func Must1[T any](result T, err error) T

func Must2

func Must2[T any, T2 any](result T, result2 T2, err error) (T, T2)

func MustCast

func MustCast[T any](obj any) T

func Ptr added in v0.3.0

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

func PtrOrNil

func PtrOrNil[T any](ptr *T) any

func PtrValueOrDefault

func PtrValueOrDefault[T any](ptr *T) T

func Reverse

func Reverse[T any](arr []T) []T

func SelectContext added in v0.2.3

func SelectContext(contextList []context.Context) (int, error)

func SortBy

func SortBy[T any, C constraints.Ordered](arr []T, block func(it T) C)

func Start

func Start(starters ...any) error

func SubstringAfter

func SubstringAfter(s string, substr string) string

func SubstringAfterLast

func SubstringAfterLast(s string, substr string) string

func SubstringBefore

func SubstringBefore(s string, substr string) string

func SubstringBeforeLast

func SubstringBeforeLast(s string, substr string) string

func SubstringBetween

func SubstringBetween(s string, after string, before string) string

func Top added in v0.2.18

func Top(obj any) any

func Uniq

func Uniq[T comparable](arr []T) []T

func UniqBy

func UniqBy[T any, C comparable](arr []T, block func(it T) C) []T

Types

type ContextCancelCauseFunc added in v0.2.3

type ContextCancelCauseFunc = context.CancelCauseFunc

type Starter

type Starter interface {
	Start() error
}

type WithUpstream

type WithUpstream interface {
	Upstream() any
}

Directories

Path Synopsis
abx
Package binary implements simple translation between numbers and byte sequences and encoding and decoding of varints.
Package binary implements simple translation between numbers and byte sequences and encoding and decoding of varints.
internal/contextjson
Package json implements encoding and decoding of JSON as defined in RFC 7159.
Package json implements encoding and decoding of JSON as defined in RFC 7159.
Package ntp provides an implementation of a Simple NTP (SNTP) client capable of querying the current time from a remote NTP server.
Package ntp provides an implementation of a Simple NTP (SNTP) client capable of querying the current time from a remote NTP server.
x
constraints
Package constraints defines a set of useful constraints to be used with type parameters.
Package constraints defines a set of useful constraints to be used with type parameters.
list
Package list implements a doubly linked list.
Package list implements a doubly linked list.

Jump to

Keyboard shortcuts

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