Documentation
¶
Overview ¶
Package coll contains functions to help manipulate and query collections of data, like slices/arrays and maps.
For the functions that return an array, a []interface{} is returned, regardless of whether or not the input was a different type.
Index ¶
- Constants
- func Append(v interface{}, list interface{}) ([]interface{}, error)
- func Dict(v ...interface{}) (map[string]interface{}, error)
- func Flatten(list interface{}, depth int) ([]interface{}, error)
- func Has(in interface{}, key interface{}) bool
- func JMESPath(jmesPath string, in interface{}) (interface{}, error)
- func JQ(ctx context.Context, jqExpr string, in interface{}) (interface{}, error)
- func JSONPath(jsonPath string, in interface{}) (interface{}, error)
- func KeyValToMap(s string) (map[string]string, error)
- func Keys(in ...map[string]any) ([]string, error)
- func MapToKeyVal[T string | any | interface{}](m map[string]T) string
- func MatchLabel(labels map[string]any, key string, valuePatterns ...string) bool
- func Merge(dst map[string]interface{}, srcs ...map[string]interface{}) (map[string]interface{}, error)
- func Omit(in map[string]interface{}, keys ...string) map[string]interface{}
- func Pick(in map[string]interface{}, keys ...string) map[string]interface{}
- func Prepend(v interface{}, list interface{}) ([]interface{}, error)
- func Reverse(list interface{}) ([]interface{}, error)
- func Slice(args ...interface{}) []interface{}
- func Sort(key string, list interface{}) (out []interface{}, err error)
- func Uniq(list interface{}) ([]interface{}, error)
- func Values(in ...map[string]interface{}) ([]interface{}, error)
Constants ¶
const NullValue = "NULL_VALUE"
Variables ¶
This section is empty.
Functions ¶
func Append ¶
func Append(v interface{}, list interface{}) ([]interface{}, error)
Append v to the end of list. No matter what type of input slice or array list is, a new []interface{} is always returned.
func Dict ¶
Dict is a convenience function that creates a map with string keys. Provide arguments as key/value pairs. If an odd number of arguments is provided, the last is used as the key, and an empty string is set as the value. All keys are converted to strings, regardless of input type.
func Flatten ¶
Flatten a nested array or slice to at most 'depth' levels. Use depth of -1 to completely flatten the input. Returns a new slice without modifying the input.
func Has ¶
func Has(in interface{}, key interface{}) bool
Has determines whether or not a given object has a property with the given key
func Keys ¶
Keys returns the list of keys in one or more maps. The returned list of keys is ordered by map, each in sorted key order.
func MapToKeyVal ¶ added in v3.24.51
func MatchLabel ¶ added in v3.24.55
MatchLabel returns true if the given map has a key that matches any of the given patterns. If all patterns are exclusions and the key doesn't exist, it's treated as a match.
func Merge ¶
func Merge(dst map[string]interface{}, srcs ...map[string]interface{}) (map[string]interface{}, error)
Merge source maps (srcs) into dst. Precedence is in left-to-right order, with the left-most values taking precedence over the right-most.
func Prepend ¶
func Prepend(v interface{}, list interface{}) ([]interface{}, error)
Prepend v to the beginning of list. No matter what type of input slice or array list is, a new []interface{} is always returned.
func Reverse ¶
func Reverse(list interface{}) ([]interface{}, error)
Reverse the list. No matter what type of input slice or array list is, a new []interface{} is always returned.
func Slice ¶
func Slice(args ...interface{}) []interface{}
Slice creates a slice from a bunch of arguments
func Sort ¶
Sort a given array or slice. Uses natural sort order if possible. If a non-empty key is given and the list elements are maps, this will attempt to sort by the values of those entries.
Does not modify the input list.
func Uniq ¶
func Uniq(list interface{}) ([]interface{}, error)
Uniq finds the unique values within list. No matter what type of input slice or array list is, a new []interface{} is always returned.
Types ¶
This section is empty.