mapping

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: MIT Imports: 1 Imported by: 27

Documentation

Overview

Package mapping provides utilities for accessing generic maps with string keys, e.g. created by parsing a YAML or JSON string, message payloads, or fields in logging or testing messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapIterator

func MapIterator(data []interface{}) (func() bool, func() Map)

func StrIterator

func StrIterator(data []interface{}) (func() bool, func() string)

Types

type Changes added in v0.1.15

type Changes map[string]changeItem

type Map

type Map map[string]interface{}

func (Map) Compare added in v0.1.15

func (old Map) Compare(new Map) Changes

Compare compares `new` and `old` and returns a mapping of changed, added, or removed items.

func (Map) Delete added in v0.1.15

func (m Map) Delete(key string)

func (Map) DeleteSpecial added in v0.1.19

func (m Map) DeleteSpecial(prefix string)

func (Map) GetIntDef added in v0.1.15

func (m Map) GetIntDef(key string, def int) int

func (Map) GetList

func (m Map) GetList(key string) []interface{}

func (Map) GetMap

func (m Map) GetMap(key string) Map

func (Map) GetStr

func (m Map) GetStr(key string) string

func (Map) GetStrDef

func (m Map) GetStrDef(key, def string) string

func (Map) GetStrDefGlob

func (m Map) GetStrDefGlob(key, def string) string

GetStrDefGlob: If key not found return default. If found expand global variable reference ($$...$$) in value.

func (Map) GetStrDefGlob1

func (m Map) GetStrDefGlob1(key, def string) string

GetStrDefGlob1: If key not found try to look it up in global vars. If found expand global variable reference in value.

func (Map) GetStrDefGlob2

func (m Map) GetStrDefGlob2(key, keyglob, def string) string

GetStrDefGlob2: If key not found try to look it up in global vars using the special key given as second parameter. If found expand global variable reference in value.

func (Map) GetStrList

func (m Map) GetStrList(key string) (r []string)

func (Map) IterateMap

func (m Map) IterateMap(key string, fct func(Map))

func (Map) IterateMapDef added in v0.1.13

func (m Map) IterateMapDef(key string, def Map, fct func(Map))

func (Map) IterateStr

func (m Map) IterateStr(key string, fct func(string))

type Vars

type Vars interface {
	Get(string) (string, bool)
	Set(string, string)
}
var GlobalVars Vars = VarsMap{}

type VarsMap

type VarsMap map[string]string

func (VarsMap) Get

func (vm VarsMap) Get(key string) (string, bool)

func (VarsMap) Set

func (vm VarsMap) Set(key, value string)

Jump to

Keyboard shortcuts

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