collections

package
v0.6.337 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCanceled is the error returned when the context is canceled.
	ErrCanceled = context.Canceled
	// ErrTimeout is the error returned when the context's deadline passes.
	ErrTimeout = context.DeadlineExceeded
)
View Source
var DefaultConverters = CopierConverters{
	timeToPBTimeStamp,
	timePtrToPBTimeStamp,
	pbTimeStampToTime,
	pbTimeStampToTimePtr,
}

Functions

func C5 added in v0.6.53

func C5[T, S, R, U, V, W any](fn02 func(some V) W, fn01 func(some U) V, fn0 func(some R) U, fn1 func(some S) R, fn2 func(some T) S) func(some T) W

func Compose added in v0.6.53

func Compose[T, S, R any](fn1 func(some S) R, fn2 func(some T) S) func(some T) R

func Concat

func Concat[T any](left, right []T) []T

func Contains added in v0.6.74

func Contains[T comparable](s []T, e T) bool

func DictMerge

func DictMerge[K comparable, V any](left, right map[K]V) map[K]V

func Difference

func Difference[T comparable](from, remove []T) []T

func Duplicate

func Duplicate[T any](x T) []T

func Fanout

func Fanout[T, R any](fs []func(T) R, item T) []R

func Filter

func Filter[T any](list []T, f func(T) bool) []T

returns those that are true

func FilterEmpty added in v0.6.74

func FilterEmpty[T comparable](l []T) []T

func Find added in v0.6.124

func Find[T any](list []T, f func(T) bool) *T

func First added in v0.6.53

func First[X any](list []X) *X

func Flatmap

func Flatmap[T, R any](fn func(some T) []R, list []T) []R

Take a list of things and a function that returns a list of things then combines list after mapping func T -> [R, R, R ...] [T, T, T ...] -> [R, R, R ...]

func Flip added in v0.6.53

func Flip[X, Y, Z any](fn func(X, Y) Z) func(Y, X) Z

func Fmap

func Fmap[T, R any](fn func(some T) R, list []T) []R

func Foldl

func Foldl[T any, R any](fn func(acc R, next T) R, base R, list []T) R

func GetRequestWithContext added in v0.6.270

func GetRequestWithContext(ctx context.Context, url string) (*http.Response, error)

getWithContext creates and sends an HTTP GET request with the provided context

func ID added in v0.6.270

func ID[T any](x T) T

func Keys added in v0.6.53

func Keys[T comparable, R any](dict map[T]R) []T

func ListContains added in v0.6.124

func ListContains[K comparable](list []K, item K) bool

func ListHas added in v0.6.124

func ListHas[K any](list []K, has func(l K) bool) bool

loops over list and returns when has returns true

func P2 added in v0.6.53

func P2[X, Y, Z any](fn func(X, Y) Z, x X) func(Y) Z

func S added in v0.6.53

func S[T any](fns ...func(some T) T) func(some T) T

func SortBy added in v0.6.53

func SortBy[T any](sortFn func(T, T) bool, list []T) []T

sortFn if i < j then ascending (1,2,3), if i > j then descending (3,2,1)

func ToDict

func ToDict[T comparable](xs []T) map[T]bool

func Uniq

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

Types

type AsyncResult added in v0.6.280

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

func Async added in v0.6.280

func Async[T any](f func() (T, error)) *AsyncResult[T]

func (*AsyncResult[T]) Await added in v0.6.280

func (ar *AsyncResult[T]) Await() (T, error)

Await blocks until the asynchronous operation completes, returning the result and error.

type ContextKey added in v0.6.288

type ContextKey string
const IdempotencyKeyName ContextKey = "idempotencyKey"

type CopierConverter added in v0.6.288

type CopierConverter interface {
	ToCopierTypeConverter() copier.TypeConverter
}

type CopierConverters added in v0.6.288

type CopierConverters []CopierConverter

type CopyConverter added in v0.6.288

type CopyConverter[T, R any] func(T) (R, error)

func (CopyConverter[T, R]) ToCopierTypeConverter added in v0.6.288

func (c CopyConverter[T, R]) ToCopierTypeConverter() copier.TypeConverter

type DoOption added in v0.6.288

type DoOption func() context.Context

DoOption defines the method to customize a DoWithTimeout call.

type MapKeyVal added in v0.6.288

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

type Params added in v0.6.124

type Params[T any] struct {
	Value T
	Ctx   context.Context
}

type Result added in v0.6.124

type Result[T any] struct {
	Value T
	Err   error
}

type Runnable added in v0.6.288

type Runnable interface {
	Run(ctx context.Context) error
	Shutdown(ctx context.Context) error
}

type TimeoutOptions added in v0.6.288

type TimeoutOptions struct {
	ParentContext context.Context
	CatchPanic    bool
}

Jump to

Keyboard shortcuts

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