Documentation ¶
Index ¶
- func ArrayConvert[F any, T any](in []F, f func(F) T) []T
- func ArrayOfElements[T any](el T) []T
- func AutoConfigure(src any, dst any) error
- func DefaultValue[T comparable](in, def T) T
- func FindArrayMember[T any](in []T, f func(check T) bool) (int, bool)
- func FromGOB64[T any](str string) (T, error)
- func IfElse[T any](cond bool, a, b T) T
- func InArray[T comparable](value T, corpus []T) bool
- func Keys[T any, K comparable](in map[K]T) []K
- func MapCopy[T any, K comparable](in map[K]T) map[K]T
- func MatcherArray[T any](in []T, f func(check T) bool) []T
- func MatcherArrayOne[T any](in []T, f func(check T) bool) (T, bool)
- func MatcherKey[T any, K comparable](in map[K]T, f func(check T) bool) []K
- func MatcherKeyOne[T any, K comparable](in map[K]T, f func(check T) bool) K
- func MatcherValue[T any, K comparable](in map[K]T, f func(check T) bool) ([]T, error)
- func MatcherValueOne[T any, K comparable](in map[K]T, f func(check T) bool) (T, error)
- func MergeMap[V comparable, T any](orig map[V]T, addl map[V]T) map[V]T
- func ObjectArrayFunc[T any, O any](in []T, f func(reduce T) O) []O
- func RemoveArrayIndex[T any](s []T, index int) []T
- func SerializeJsonToFile[T any](fn string, data T) error
- func SerializeJsonToWriter[T any](w io.Writer, data T) error
- func SingleValueDiscardError[T any](ret T, err error) T
- func ToGOB64[T any](m T) (string, error)
- func TypeConvert[T any](v any) T
- func UnserializeJsonFromFile[T any](fn string) (T, error)
- func UnserializeJsonFromReader[T any](r io.Reader) (T, error)
- func Values[T any, U comparable](in map[U]T) []T
- type GOB64Serializer
- type JsonSerializer
- type Serializer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArrayConvert ¶
ArrayConvert converts an array of one type to an array of another via an arbitrary transform function.
func ArrayOfElements ¶
func ArrayOfElements[T any](el T) []T
ArrayOfElements creates an array from a type.
func AutoConfigure ¶
func DefaultValue ¶
func DefaultValue[T comparable](in, def T) T
DefaultValue determines if the input is value (not empty), and if it is, returns the input value, otherwise returns a provided default.
func FindArrayMember ¶
FindArrayMember locates an array element by arbitrary criteria
func InArray ¶
func InArray[T comparable](value T, corpus []T) bool
InArray returns a bool value indicating whether value is found in corpus.
func Keys ¶
func Keys[T any, K comparable](in map[K]T) []K
Keys returns an array of keys in an arbitrary map.
func MapCopy ¶
func MapCopy[T any, K comparable](in map[K]T) map[K]T
MapCopy creates a copy of a map
func MatcherArray ¶
MatcherArray returns all members that match using an arbitrary matching function.
func MatcherArrayOne ¶
MatcherArrayOne returns the first array member that matches using an arbitrary function. It returns a second parameter indicating whether or not a match had been made, to differentiate from the zero value for the type.
func MatcherKey ¶
func MatcherKey[T any, K comparable](in map[K]T, f func(check T) bool) []K
MatcherKey returns a list of matched keys from an arbitrarily keyed map
func MatcherKeyOne ¶
func MatcherKeyOne[T any, K comparable](in map[K]T, f func(check T) bool) K
MatcherKeyOne returns the first matched key from an arbitrarily keyed map
func MatcherValue ¶
func MatcherValue[T any, K comparable](in map[K]T, f func(check T) bool) ([]T, error)
MatcherValue returns the matched values from an arbitrarily keyed map
func MatcherValueOne ¶
func MatcherValueOne[T any, K comparable](in map[K]T, f func(check T) bool) (T, error)
MatcherValue returns the first matched value from an arbitrarily keyed map
func MergeMap ¶
func MergeMap[V comparable, T any](orig map[V]T, addl map[V]T) map[V]T
MergeMap merges two of the same type of maps together, overwriting values with the additional data.
func ObjectArrayFunc ¶
ObjectArrayFunc executes an arbitrary function to reduce an array of objects to an array of arbitrary values.
func RemoveArrayIndex ¶
RemoveArrayIndex removes an element from an array
func SerializeJsonToFile ¶
SerializeJsonToFile serializes an arbitrary data type in JSON to the specified file
func SerializeJsonToWriter ¶
SerializeJsonToWriter serializes an arbitrary data type in JSON to the specified io.Writer
func SingleValueDiscardError ¶
SingleValueDiscardError is used to wrap a single value function and discard the additional error.
func TypeConvert ¶
TypeConvert is a convenience function to force cast
func UnserializeJsonFromFile ¶
UnserializeJsonFromFile deserializes a JSON representation from a specified file into an arbitrary object
func UnserializeJsonFromReader ¶
UnserializeJsonFromReader deserializes a JSON representation from a specified io.Reader into an arbitrary object
func Values ¶
func Values[T any, U comparable](in map[U]T) []T
Values returns an array of values in an arbitrary keyed map.
Types ¶
type GOB64Serializer ¶
type GOB64Serializer[T any] struct { }
func (GOB64Serializer[T]) FromFile ¶
func (s GOB64Serializer[T]) FromFile(fn string) (T, error)
FromFile deserializes a GOB64 representation from a specified file into an arbitrary object
func (GOB64Serializer[T]) FromReader ¶
func (s GOB64Serializer[T]) FromReader(r io.Reader) (T, error)
FromWriter deserializes a GOB64 representation from a specified io.Reader into an arbitrary object
func (GOB64Serializer[T]) ToFile ¶
func (s GOB64Serializer[T]) ToFile(fn string, data T) error
ToFile serializes an arbitrary data type in GOB64 to the specified file
type JsonSerializer ¶
type JsonSerializer[T any] struct { }
func (JsonSerializer[T]) FromFile ¶
func (s JsonSerializer[T]) FromFile(fn string) (T, error)
FromFile deserializes a JSON representation from a specified file into an arbitrary object
func (JsonSerializer[T]) FromReader ¶
func (s JsonSerializer[T]) FromReader(r io.Reader) (T, error)
FromWriter deserializes a JSON representation from a specified io.Reader into an arbitrary object
func (JsonSerializer[T]) ToFile ¶
func (s JsonSerializer[T]) ToFile(fn string, data T) error
ToFile serializes an arbitrary data type in JSON to the specified file