datamap

package
v0.0.0-...-b44964e Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: Apache-2.0, Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataMap

type DataMap struct {
	// contains filtered or unexported fields
}

DataMap is a hierarchical data structure which allows clients to get and set values by their JavaScript-like paths, e.g. "foo.bar.baz". It can also have get-fail-handler, which is invoked if Get fails to find value at the provided path. This way, clients can have some "phantom" values.

func New

func New(getFailHandler GetFailHandler) *DataMap

New creates new DataMap with the provided GetFailHandler.

func (*DataMap) Copy

func (dm *DataMap) Copy() *DataMap

func (*DataMap) Get

func (dm *DataMap) Get(name string) (interface{}, bool)

Get gets value at the provided name (path), like "foo.bar.baz". If value is not found, returned bool is false.

func (*DataMap) Set

func (dm *DataMap) Set(name string, value interface{})

Set sets new value at the provided name (path), like "foo.bar.baz". All intermediary non-existing parts will be silently created.

type GetFailHandler

type GetFailHandler func(dm *DataMap, name string) (interface{}, bool)

GetFailHandler, if specified, is called when DataMap.Get fails to get the value normally. This way, client can create some "phantom" values.

Jump to

Keyboard shortcuts

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