stringmap

package
v0.33.5 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: GPL-2.0, GPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package stringmap contains convenience functions for maps with string keys

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetValueInMap

func GetValueInMap(searchedMap map[string]interface{}, path ...string) (interface{}, error)

GetValueInMap returns the value of a nested StringMap at the specified path

func HaveValueInMap added in v0.32.32

func HaveValueInMap(searchedMap map[string]interface{}, path ...string) bool

HaveValueInMap indicates whether the nested StringMap has a value at the specified path

func MergeIntoMap

func MergeIntoMap(subject StringMap, otherMap StringMap) error

MergeIntoMap deep merges values from one StringMap into another

For each key path at which subject does not have a value, this will set the value from otherMap even if subject has a value at a prefix of the key path. Existing values - including nil - at matching complete paths will not be overwritten.

func RemoveValueInMap added in v0.32.12

func RemoveValueInMap(mapToChange map[string]interface{}, path ...string) error

RemoveValueInMap removes the value of a nested StringMap at the specified path

Trying to remove a non-existent value returns an error.

func SetValueInMap

func SetValueInMap(mapToChange map[string]interface{}, value interface{}, path ...string) error

SetValueInMap fixes the value of a nested StringMap at the specified path

Additional levels of nesting will be created if necessary.

Types

type StringMap

type StringMap = map[string]interface{}

StringMap is a map with string keys and arbitrary values

func CopyMap

func CopyMap(otherMap StringMap) StringMap

CopyMap creates a deep copy of a StringMap

The copy can be safely mutated without changing nested keys of the original StringMap.

Jump to

Keyboard shortcuts

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