Documentation ¶
Index ¶
- func CleanConfigStringMap(m map[string]any) map[string]any
- func CleanConfigStringMapString(m map[string]string) map[string]string
- func ConvertFloat64WithNoDecimalsToInt(m map[string]any)
- func GetNestedParam(keyStr, separator string, candidates ...Params) (any, error)
- func GetNestedParamFn(keyStr, separator string, lookupFn func(key string) any) (any, string, map[string]any, error)
- func LookupEqualFold[T any | string](m map[string]T, key string) (T, string, bool)
- func MergeParams(dst, src Params)
- func MergeParamsWithStrategy(strategy string, dst, src Params)
- func MergeShallow(dst, src map[string]any)
- func PrepareParams(m Params)
- func SetParams(dst, src Params)
- func ToSliceStringMap(in any) ([]map[string]any, error)
- func ToStringMap(in any) map[string]any
- func ToStringMapBool(in any) map[string]bool
- func ToStringMapE(in any) (map[string]any, error)
- func ToStringMapString(in any) map[string]string
- func ToStringMapStringE(in any) (map[string]string, error)
- type Cache
- func (c *Cache[K, T]) Drain() map[K]T
- func (c *Cache[K, T]) ForEeach(f func(K, T))
- func (c *Cache[K, T]) Get(key K) (T, bool)
- func (c *Cache[K, T]) GetOrCreate(key K, create func() (T, error)) (T, error)
- func (c *Cache[K, T]) InitAndGet(key K, init func(get func(key K) (T, bool), set func(key K, value T)) error) (T, error)
- func (c *Cache[K, T]) Len() int
- func (c *Cache[K, T]) Reset()
- func (c *Cache[K, T]) Set(key K, value T)
- type KeyParams
- type KeyRenamer
- type Params
- type ParamsMergeStrategy
- type Scratch
- func (c *Scratch) Add(key string, newAddend any) (string, error)
- func (c *Scratch) Delete(key string) string
- func (c *Scratch) DeleteInMap(key string, mapKey string) string
- func (c *Scratch) Get(key string) any
- func (c *Scratch) GetSortedMapValues(key string) any
- func (c *Scratch) Set(key string, value any) string
- func (c *Scratch) SetInMap(key string, mapKey string, value any) string
- func (c *Scratch) Values() map[string]any
- type SliceCache
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanConfigStringMap ¶ added in v0.112.0
CleanConfigStringMap is the same as CleanConfigStringMapString but for map[string]any.
func CleanConfigStringMapString ¶ added in v0.112.0
CleanConfigStringMapString removes any processing instructions from m, m will never be modified.
func ConvertFloat64WithNoDecimalsToInt ¶ added in v0.118.0
ConvertFloat64WithNoDecimalsToInt converts float64 values with no decimals to int recursively.
func GetNestedParam ¶ added in v0.56.0
GetNestedParam gets the first match of the keyStr in the candidates given. It will first try the exact match and then try to find it as a nested map value, using the given separator, e.g. "mymap.name". It assumes that all the maps given have lower cased keys.
func GetNestedParamFn ¶ added in v0.56.0
func LookupEqualFold ¶ added in v0.97.0
LookupEqualFold finds key in m with case insensitive equality checks.
func MergeParams ¶ added in v0.112.0
func MergeParams(dst, src Params)
MergeParams transfers values from src to dst for new keys using the merge encoded in dst. This is done recursively.
func MergeParamsWithStrategy ¶ added in v0.112.0
MergeParamsWithStrategy transfers values from src to dst for new keys using the merge strategy given. This is done recursively.
func MergeShallow ¶ added in v0.112.0
MergeShallow merges src into dst, but only if the key does not already exist in dst. The keys are compared case insensitively.
func PrepareParams ¶ added in v0.84.0
func PrepareParams(m Params)
PrepareParams * makes all the keys in the given map lower cased and will do so * This will modify the map given. * Any nested map[interface{}]interface{}, map[string]interface{},map[string]string will be converted to Params. * Any _merge value will be converted to proper type and value.
func SetParams ¶ added in v0.112.0
func SetParams(dst, src Params)
SetParams overwrites values in dst with values in src for common or new keys. This is done recursively.
func ToSliceStringMap ¶ added in v0.77.0
ToSliceStringMap converts in to []map[string]interface{}.
func ToStringMap ¶ added in v0.60.0
ToStringMap converts in to map[string]interface{}.
func ToStringMapBool ¶ added in v0.84.0
ToStringMapBool converts in to bool.
func ToStringMapE ¶ added in v0.60.0
ToStringMapE converts in to map[string]interface{}.
func ToStringMapString ¶ added in v0.84.0
ToStringMapString converts in to map[string]string.
Types ¶
type Cache ¶ added in v0.123.0
type Cache[K comparable, T any] struct { sync.RWMutex // contains filtered or unexported fields }
Cache is a simple thread safe cache backed by a map.
func NewCache ¶ added in v0.123.0
func NewCache[K comparable, T any]() *Cache[K, T]
NewCache creates a new Cache.
func (*Cache[K, T]) ForEeach ¶ added in v0.126.0
func (c *Cache[K, T]) ForEeach(f func(K, T))
ForEeach calls the given function for each key/value pair in the cache.
func (*Cache[K, T]) Get ¶ added in v0.123.0
Delete deletes the given key from the cache. If c is nil, this method is a no-op.
func (*Cache[K, T]) GetOrCreate ¶ added in v0.123.0
GetOrCreate gets the value for the given key if it exists, or creates it if not.
func (*Cache[K, T]) InitAndGet ¶ added in v0.138.0
func (c *Cache[K, T]) InitAndGet(key K, init func(get func(key K) (T, bool), set func(key K, value T)) error) (T, error)
InitAndGet initializes the cache if not already done and returns the value for the given key. The init state will be reset on Reset or Drain.
type KeyRenamer ¶ added in v0.54.0
type KeyRenamer struct {
// contains filtered or unexported fields
}
KeyRenamer supports renaming of keys in a map.
func NewKeyRenamer ¶ added in v0.54.0
func NewKeyRenamer(patternKeys ...string) (KeyRenamer, error)
NewKeyRenamer creates a new KeyRenamer given a list of pattern and new key value pairs.
func (KeyRenamer) Rename ¶ added in v0.54.0
func (r KeyRenamer) Rename(m map[string]any)
Rename renames the keys in the given map according to the patterns in the current KeyRenamer.
type Params ¶ added in v0.60.0
Params is a map where all keys are lower case.
func MustToParamsAndPrepare ¶ added in v0.84.1
MustToParamsAndPrepare calls ToParamsAndPrepare and panics if it fails.
func ToParamsAndPrepare ¶ added in v0.84.0
ToParamsAndPrepare converts in to Params and prepares it for use. If in is nil, an empty map is returned. See PrepareParams.
func (Params) DeleteMergeStrategy ¶ added in v0.84.0
For internal use.
func (Params) GetMergeStrategy ¶ added in v0.84.0
func (p Params) GetMergeStrategy() (ParamsMergeStrategy, bool)
For internal use.
func (Params) GetNested ¶ added in v0.112.0
GetNested does a lower case and nested search in this map. It will return nil if none found. Make all of these methods internal somehow.
func (Params) SetMergeStrategy ¶ added in v0.112.0
func (p Params) SetMergeStrategy(s ParamsMergeStrategy)
For internal use.
type ParamsMergeStrategy ¶ added in v0.84.0
type ParamsMergeStrategy string
ParamsMergeStrategy tells what strategy to use in Params.Merge.
const ( // Do not merge. ParamsMergeStrategyNone ParamsMergeStrategy = "none" // Only add new keys. ParamsMergeStrategyShallow ParamsMergeStrategy = "shallow" // Add new keys, merge existing. ParamsMergeStrategyDeep ParamsMergeStrategy = "deep" MergeStrategyKey = "_merge" )
type Scratch ¶ added in v0.45.1
type Scratch struct {
// contains filtered or unexported fields
}
Scratch is a writable context used for stateful operations in Page/Node rendering.
func NewScratch ¶ added in v0.45.1
func NewScratch() *Scratch
NewScratch returns a new instance of Scratch.
func (*Scratch) Add ¶ added in v0.45.1
Add will, for single values, add (using the + operator) the addend to the existing addend (if found). Supports numeric values and strings.
If the first add for a key is an array or slice, then the next value(s) will be appended.
func (*Scratch) DeleteInMap ¶ added in v0.84.0
DeleteInMap deletes a value to a map with the given key in the Node context.
func (*Scratch) GetSortedMapValues ¶ added in v0.45.1
GetSortedMapValues returns a sorted map previously filled with SetInMap.
func (*Scratch) Set ¶ added in v0.45.1
Set stores a value with the given key in the Node context. This value can later be retrieved with Get.
type SliceCache ¶ added in v0.123.0
SliceCache is a simple thread safe cache backed by a map.
func NewSliceCache ¶ added in v0.123.0
func NewSliceCache[T any]() *SliceCache[T]
func (*SliceCache[T]) Append ¶ added in v0.123.0
func (c *SliceCache[T]) Append(key string, values ...T)
func (*SliceCache[T]) Get ¶ added in v0.123.0
func (c *SliceCache[T]) Get(key string) ([]T, bool)
func (*SliceCache[T]) Reset ¶ added in v0.123.0
func (c *SliceCache[T]) Reset()