maps

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package maps contains methods to operate maps of all kinds

Package maps contains methods to operate maps of all kinds

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsBool added in v0.8.0

func AsBool(data map[string]string, key string) (*bool, error)

AsBool will parse value in data["key"] to bool if the key not exist, it will return nil if the value is not a valid bool string, it will return error

func AsObject added in v0.8.0

func AsObject(data map[string]string, key string, object interface{}) error

AsObject will parse value in data["key"] to object it expects the value should be yaml content

func IsSameStringMap added in v0.8.0

func IsSameStringMap(first map[string]string, second map[string]string) bool

IsSameStringMap return true if provided two map[string]string are same or false if they are different

func MergeMap

func MergeMap(left, right map[string]string) map[string]string

MergeMap merges the right map into left map overwritting any matching keys

func MergeMapIfNotExists added in v0.8.0

func MergeMapIfNotExists(left, right map[string]string) map[string]string

MergeMapIfNotExists merges the right map into left map if right key is not exists in left

func MergeMapMap

func MergeMapMap(left, right map[string]map[string]string) map[string]map[string]string

MergeMapMap merges the right map into left map overwritting any matching keys

func MergeMapSlice

func MergeMapSlice(left, right map[string][]string) map[string][]string

MergeMapSlice merges the right map into left map overwritting any matching keys

func SelectAndMutateMap added in v0.11.0

func SelectAndMutateMap(maps map[string]string, match MatchFunc, mutate MutateFunc) map[string]string

SelectAndMutateMap select elements from a map based on a match function and mutate it's key and value

Types

type KeyValue

type KeyValue struct {
	// Key of the map
	Key string
	// Value of string map
	Value string
}

KeyValue a key/value pair just like a map[string]string

func SortedKeyValue

func SortedKeyValue(dict map[string]string) (items []KeyValue)

SortedKeyValue returns a list of key values sorted by key

type MatchFunc added in v0.11.0

type MatchFunc func(key, value string) bool

MatchFunc return true if key and value match condition

type MutateFunc added in v0.11.0

type MutateFunc func(key, value string) (string, string)

MutateFunc return mutated key and value

Jump to

Keyboard shortcuts

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