maps

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2025 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

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

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

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

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

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

type MatchFunc func(key, value string) bool

MatchFunc return true if key and value match condition

type MutateFunc

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