got

package module
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: MIT Imports: 1 Imported by: 0

README

Overview

Package GOT implements frequently used functions and algorithms (mostly functional programming).

Installation

go get github.com/jokruger/got

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func And

func And[T any](preds ...func(T) bool) func(T) bool

And returns a predicate that returns true if all predicates return true.

func False

func False[T any](T) bool

False returns a predicate that always returns false.

func Flip

func Flip[T, R any](f func(T, T) R) func(T, T) R

Flip returns a function that swaps the arguments of a binary function.

func InContainer

func InContainer[T any](s Container[T]) func(T) bool

InContainer returns a predicate that checks if a value is in container.

func InMap

func InMap[K comparable, V any](m map[K]V) func(K) bool

InMap returns a predicate that checks if a key is in a map.

func InSeq

func InSeq[T comparable](s iter.Seq[T]) func(T) bool

InSeq returns a predicate that checks if a value is in a sequence.

func InSet

func InSet[T comparable](s map[T]struct{}) func(T) bool

InSet returns a predicate that checks if a value is in a set.

func InSlice

func InSlice[T comparable](s []T) func(T) bool

InSlice returns a predicate that checks if a value is in a slice.

func Not

func Not[T any](f func(T) bool) func(T) bool

Not returns a predicate that negates the result of the given predicate.

func Or

func Or[T any](preds ...func(T) bool) func(T) bool

Or returns a predicate that returns true if any of the predicates return true.

func Ternary

func Ternary[T any](a T, b T, f func() bool) T

Ternary returns a if f() is true, otherwise b.

func True

func True[T any](T) bool

True returns a predicate that always returns true.

Types

type AccountIDProvider

type AccountIDProvider[T any] interface {
	GetAccountID() T
}

AccountIDProvider defines types that implements the GetAccountID method.

type AmountProvider

type AmountProvider[T any] interface {
	GetAmount() T
}

AmountProvider defines types that implements the GetAmount method.

type Comparable

type Comparable[T any] interface {
	Compare(T) int
}

Comparable defines types that implements the Compare method.

type Container

type Container[T any] interface {
	Contains(T) bool
}

Container defines types that implements the Contains method.

type CreatedAtProvider

type CreatedAtProvider[T any] interface {
	GetCreatedAt() T
}

CreatedAtProvider defines types that implements the GetCreatedAt method.

type CustomerIDProvider

type CustomerIDProvider[T any] interface {
	GetCustomerID() T
}

CustomerIDProvider defines types that implements the GetCustomerID method.

type EventIDProvider

type EventIDProvider[T any] interface {
	GetEventID() T
}

EventIDProvider defines types that implements the GetEventID method.

type EventNameProvider

type EventNameProvider[T any] interface {
	GetEventName() T
}

EventNameProvider defines types that implements the GetEventName method.

type Identifiable

type Identifiable[T any] interface {
	GetID() T
}

Identifiable defines types that implements the GetID method.

type Integer

type Integer interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64
}

Integer defines numeric types that are integers (signed or unsigned).

type Named

type Named[T any] interface {
	GetName() T
}

Named defines types that implements the GetName method.

type Numeric

type Numeric interface {
	Integer | ~float32 | ~float64
}

Numeric defines numeric types that can be either integers or floating-point numbers.

type Ordered

type Ordered interface {
	Integer | ~float32 | ~float64 | ~string
}

Ordered defines types that can be ordered.

type PriorityProvider

type PriorityProvider[T any] interface {
	GetPriority() T
}

PriorityProvider defines types that implements the GetPriority method.

type ProductIDProvider

type ProductIDProvider[T any] interface {
	GetProductID() T
}

ProductIDProvider defines types that implements the GetProductID method.

type TransactionIDProvider

type TransactionIDProvider[T any] interface {
	GetTransactionID() T
}

TransactionIDProvider defines types that implements the GetTransactionID method.

type UpdatedAtProvider

type UpdatedAtProvider[T any] interface {
	GetUpdatedAt() T
}

UpdatedAtProvider defines types that implements the GetUpdatedAt method.

type ValueTimeProvider

type ValueTimeProvider[T any] interface {
	GetValueTime() T
}

ValueTimeProvider defines types that implements the GetValueTime method.

type ZeroCheckable

type ZeroCheckable interface {
	IsZero() bool
}

ZeroCheckable defines types that implements the IsZero method.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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