utils

package
v0.0.0-...-9c00e75 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTokenizer = StringTokenizer(".")

DefaultTokenizer is a tokenizer using a dot or fullstop

Functions

This section is empty.

Types

type Map

type Map struct {
	M map[string]interface{}
	// contains filtered or unexported fields
}

Map is a flatten map

func Flatten

func Flatten(m map[string]interface{}, tokenizer Tokenizer) (*Map, error)

Flatten takes a hierarchy and flatten it using the tokenizer supplied

func (*Map) Del

func (m *Map) Del(prefix string)

Del deletes a key out of the map with the given prefix

func (*Map) Expand

func (m *Map) Expand() map[string]interface{}

Expand expands the Map into a more complex structure. This is the reverse of the Flatten operation.

func (*Map) Move

func (m *Map) Move(original, newKey string)

Move makes changes in the flatten hierarchy moving contents from origin to newKey

type StringTokenizer

type StringTokenizer string

StringTokenizer is a Tokenizer using the string as separator

func (StringTokenizer) Keys

func (s StringTokenizer) Keys(ks string) []string

Keys returns the keys contained in the received token

func (StringTokenizer) Separator

func (s StringTokenizer) Separator() string

Separator returns the separator

func (StringTokenizer) Token

func (s StringTokenizer) Token(ks []string) string

Token returns a token joining all the keys with s as separator

type Tokenizer

type Tokenizer interface {
	Separator() string
	Token([]string) string
	Keys(string) []string
}

Tokenizer is an interface for key manipulators

Jump to

Keyboard shortcuts

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