data

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection []interface{}

Collection represents a slice of interface{} (generic type)

func NewCollection

func NewCollection() *Collection

NewCollection creates a new collection and returns a pointer

func (*Collection) PadWithMap

func (s *Collection) PadWithMap(size int)

PadWithMap creates missing elements with a map

func (*Collection) Push

func (s *Collection) Push(value interface{})

Push appends provided value to the slice

func (*Collection) Range

func (s *Collection) Range(handler func(item interface{}, index int) (bool, error)) error

Range iterates over every item in this collection as long as handler returns true. Handler takes an index and index of the slice element.

func (*Collection) RangeInt

func (s *Collection) RangeInt(handler func(item interface{}, index int) (bool, error)) error

RangeMap iterates every int item in this collection as long as handler returns true. Handler takes an index and index of the slice element

func (*Collection) RangeMap

func (s *Collection) RangeMap(handler func(item Map, index int) (bool, error)) error

RangeMap iterates every map item in this collection as long as handler returns true. Handler takes an index and index of the slice element

func (*Collection) RangeString

func (s *Collection) RangeString(handler func(item interface{}, index int) (bool, error)) error

RangeMap iterates every string item in this collection as long as handler returns true. Handler takes an index and index of the slice element

func (*Collection) String

func (s *Collection) String() string

String returns a string representation of this collection

type Map

type Map map[string]interface{}

Map types is an alias type to map[string]interface{} with extended behaviours

func NewMap

func NewMap() Map

NewMap creates a new instance of a map.

func (*Map) Apply

func (s *Map) Apply(source map[string]interface{})

Apply copies all elements of provided map to this map.

func (*Map) AsEncodableMap

func (s *Map) AsEncodableMap() map[string]interface{}

Returns a map that can be encoded by json or other decoders. Since a map can store a function, it filters out any non marshalable types.

func (*Map) Clone

func (s *Map) Clone() Map

Clones create a clone of this map.

func (*Map) Delete

func (s *Map) Delete(keys ...string)

Delete removes the supplied keys

func (*Map) Expand

func (s *Map) Expand(source interface{}) interface{}

Expand expands provided value of any type with dollar sign expression/

func (*Map) ExpandAsText

func (s *Map) ExpandAsText(text string) string

ExpandAsText expands all matching expressions starting with dollar sign ($)

func (*Map) Get

func (s *Map) Get(key string) interface{}

Get returns a value for provided key

func (*Map) GetBoolean

func (s *Map) GetBoolean(key string) bool

GetBoolean returns value for provided key as boolean.

func (*Map) GetCollection

func (s *Map) GetCollection(key string) *Collection

GetCollection returns value for provided key as collection pointer.

func (*Map) GetFloat

func (s *Map) GetFloat(key string) float64

GetFloat returns value for provided key as float64.

func (*Map) GetInt

func (s *Map) GetInt(key string) int

GetInt returns value for provided key as int.

func (*Map) GetMap

func (s *Map) GetMap(key string) Map

GetMap returns value for provided key as map.

func (*Map) GetString

func (s *Map) GetString(key string) string

GetString returns value for provided key as string.

func (*Map) GetValue

func (s *Map) GetValue(expr string) (interface{}, bool)

GetValue returns value for provided expression. The expression uses dot (.) to denote nested data structure. The following expression as supported

  1. <-key shift
  2. ++key pre increment
  3. key++ post increment
  4. $key reference access

func (*Map) Has

func (s *Map) Has(key string) bool

Has returns true if the provided key is present

func (*Map) Put

func (s *Map) Put(key string, value interface{})

Put puts key value into the map.

func (*Map) Range

func (s *Map) Range(callback func(k string, v interface{}) (bool, error)) error

Range iterates every key, value pair of this map, calling supplied callback as long it does return true.

func (*Map) SetValue

func (s *Map) SetValue(expr string, value interface{})

Set value sets value in the map for the supplied expression. The expression uses dot (.) to denote nested data structure. For instance the following expression key1.subKey1.attr1 Would take or create map for key1, followied bu takeing or creating antother map for subKey1 to set attr1 key with provided value The following expression as supported

  1. $key reference - the final key is determined from key's content.
  2. ->key push expression to append value at the end of the slice

type Udf

type Udf func(interface{}, Map) (interface{}, error)

Udf represents a user defined function used to transform data.

Jump to

Keyboard shortcuts

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