Documentation ¶
Overview ¶
Package key_value defines the custom map and its additional functions.
The package defines two different data types:
- KeyValue is the map where the key is a string, and value could be anything. It defines additional functions that returns the value converted to the desired type.
- List is the list of elements but based on the map. For the user the list acts as the array. However internal it uses map for optimization.
Index ¶
- Constants
- type KeyValue
- func (k KeyValue) Bytes() ([]byte, error)
- func (k KeyValue) Exist(name string) error
- func (k KeyValue) GetBigNumber(name string) (*big.Int, error)
- func (k KeyValue) GetBoolean(name string) (bool, error)
- func (k KeyValue) GetFloat64(name string) (float64, error)
- func (k KeyValue) GetKeyValue(name string) (KeyValue, error)
- func (k KeyValue) GetKeyValueList(name string) ([]KeyValue, error)
- func (k KeyValue) GetString(name string) (string, error)
- func (k KeyValue) GetStringList(name string) ([]string, error)
- func (k KeyValue) GetUint64(name string) (uint64, error)
- func (k KeyValue) Interface(i interface{}) error
- func (k KeyValue) Map() map[string]interface{}
- func (k KeyValue) Set(name string, value interface{}) KeyValue
- func (k KeyValue) String() (string, error)
- type List
Constants ¶
const ListLength = 1_000_000
ListLength max amount of data that this list could keep
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type KeyValue ¶
type KeyValue map[string]interface{}
KeyValue is the golang's map with the functions. Important to know that, no value could be `nil`.
func NewFromInterface ¶
NewFromInterface converts the data structure "i" to KeyValue In order to do that, it serializes data structure using json
The data structures should define the json variable names
func NewFromString ¶
NewFromString converts the s string with a json decoder into the key value
func (KeyValue) GetBigNumber ¶
GetBigNumber extracts the value as the parsed large number. Use this, if the number size is more than 64 bits.
func (KeyValue) GetBoolean ¶
GetBoolean extracts the value as boolean
func (KeyValue) GetFloat64 ¶
GetFloat64 extracts the float number
func (KeyValue) GetKeyValue ¶
GetKeyValue returns the parameter as a KeyValue
func (KeyValue) GetKeyValueList ¶
GetKeyValueList returns the parameter as a slice of map:
[]key_value.KeyValue
func (KeyValue) GetStringList ¶
GetStringList returns the list of strings
type List ¶
type List struct {
// contains filtered or unexported fields
}
func NewList ¶
func NewList() *List
NewList returns a new list of the elements that could contain maximum LIST_LENGTH amount of elements.
The queue has a function that returns the first element by taking it out from the list.
The added elements attached after the last element.
func (*List) Add ¶
Add a new element to the queue. If the element type is not the same as the expected type, then It will silently drop it. Silently drop if the queue is full