Documentation ¶
Index ¶
- func AddFlagAliasesBool(flags *pflag.FlagSet, originalFlag string, aliasMap map[string][]string, ...)
- func AddFlagAliasesString(flags *pflag.FlagSet, originalFlag string, aliasMap map[string][]string, ...)
- func AddFlagAliasesStringSlice(flags *pflag.FlagSet, originalFlag string, aliasMap map[string][]string, ...)
- func ApplyFlagAliases(flags *pflag.FlagSet, aliases map[string][]string)
- func ExtractValuesMatchingKeys[T any](collection []T, keys []string, idSelector func(T) string, ...) []string
- func MapCollectionWithLookups[T any, TResult any](cacheContainer *MapCollectionCacheContainer, collection []T, ...) ([]TResult, error)
- func SliceContains[T comparable](slice []T, target T) bool
- func SliceContainsAny[T comparable](slice []T, predicate func(item T) bool) bool
- func SliceFilter[T any](slice []T, predicate func(item T) bool) []T
- func SliceTransform[T any, TResult any](slice []T, transform func(item T) TResult) []TResult
- type MapCollectionCacheContainer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFlagAliasesBool ¶
func AddFlagAliasesString ¶
func AddFlagAliasesStringSlice ¶ added in v0.2.1
func ApplyFlagAliases ¶ added in v0.2.1
func ExtractValuesMatchingKeys ¶
func ExtractValuesMatchingKeys[T any](collection []T, keys []string, idSelector func(T) string, valueSelector func(T) string) []string
ExtractValuesMatchingKeys returns a collection of values which matched a specified set of keys, in the exact order of keys. Given a collection of items, and a collection of keys to match within that collection This makes no sense, hopefully an example helps: - Given an array of Channels [<id:C1, name:'C1Name'>, <id:C7, name:'C7Name'> , <id:C2, name:'C2Name'>] - And a set of keys [C2, C7] - Returns the extracted values ['C2Name', 'C7Name']
Note: if something can't be found, then the extracted values collection will contain a zero value in-place
func MapCollectionWithLookups ¶
func MapCollectionWithLookups[T any, TResult any]( cacheContainer *MapCollectionCacheContainer, collection []T, keySelector func(T) []string, mapper func(T, []string) TResult, runLookups ...func([]string) ([]string, error), ) ([]TResult, error)
MapCollectionWithLookups does a 'map' operation over the collection, transforming each input row into an output row according to `mapper`, however it also provides the ability to collect ID's of related items as it iterates the collection, and call out to lambdas to look those values up. See the unit tests for examples which should clarify the use-cases for this.
func SliceContains ¶
func SliceContains[T comparable](slice []T, target T) bool
SliceContains returns true if it finds an item in the slice that is equal to the target
func SliceContainsAny ¶ added in v0.2.1
func SliceContainsAny[T comparable](slice []T, predicate func(item T) bool) bool
SliceContainsAny returns true if it finds an item in the slice where `predicate` returns true
func SliceFilter ¶
SliceFilter takes an input collection and returns elements where `predicate` returns true Known as 'filter' in most other languages or 'Select' in C# Linq.
func SliceTransform ¶
SliceTransform takes an input collection, applies the transform function to each row, and returns the output. Known as 'map' in most other languages or 'Select' in C# Linq.