Documentation ¶
Index ¶
- func ConvertArrayMapStrInto(datas []MapStr, output interface{}) error
- func GetTags(target interface{}, tagName string) []string
- func IsNil(value interface{}) bool
- func SetValueToStructByTags(target interface{}, values MapStr) error
- func SetValueToStructByTagsWithTagName(target interface{}, values MapStr, tagName string) error
- type MapStr
- func New() MapStr
- func NewArray() []MapStr
- func NewArrayFromInterface(datas []map[string]interface{}) []MapStr
- func NewArrayFromMapStr(datas []MapStr) []MapStr
- func NewFromInterface(data interface{}) (MapStr, error)
- func NewFromMap(data map[string]interface{}) MapStr
- func NewFromStruct(targetStruct interface{}, tagName string) MapStr
- func SetValueToMapStrByTags(source interface{}) MapStr
- func SetValueToMapStrByTagsWithTagName(source interface{}, tagName string) MapStr
- func (cli MapStr) Bool(key string) (bool, error)
- func (cli MapStr) Clone() MapStr
- func (cli MapStr) Different(target MapStr) (more MapStr, less MapStr, changes MapStr)
- func (cli MapStr) Exists(key string) bool
- func (cli MapStr) Float(key string) (float64, error)
- func (cli MapStr) ForEach(callItem func(key string, val interface{}) error) error
- func (cli MapStr) Get(key string) (val interface{}, exists bool)
- func (cli MapStr) Int64(key string) (int64, error)
- func (cli MapStr) IsEmpty() bool
- func (cli MapStr) MapStr(key string) (MapStr, error)
- func (cli MapStr) MapStrArray(key string) ([]MapStr, error)
- func (cli MapStr) MarshalJSONInto(target interface{}) error
- func (cli MapStr) Merge(second MapStr)
- func (cli MapStr) Remove(key string) interface{}
- func (cli MapStr) Reset()
- func (cli MapStr) Set(key string, value interface{})
- func (cli MapStr) String(key string) (string, error)
- func (cli MapStr) Time(key string) (*time.Time, error)
- func (cli MapStr) ToJSON() ([]byte, error)
- func (cli MapStr) ToMapInterface() map[string]interface{}
- func (cli MapStr) ToStructByTag(targetStruct interface{}, tagName string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertArrayMapStrInto ¶
ConvertArrayMapStrInto convert a MapStr array into a new slice instance
func IsNil ¶
func IsNil(value interface{}) bool
IsNil returns whether value is nil value, including map[string]interface{}{nil}, *Struct{nil}
func SetValueToStructByTags ¶
SetValueToStructByTags set the struct object field value by tags, default tag name is field
func SetValueToStructByTagsWithTagName ¶
SetValueToStructByTagsWithTagName set the struct object field value by tags
Types ¶
type MapStr ¶
type MapStr map[string]interface{}
MapStr the common event data definition
func NewArrayFromInterface ¶
NewArrayFromInterface create a new array from interface
func NewArrayFromMapStr ¶
NewArrayFromMapStr create a new array from mapstr array
func NewFromInterface ¶
NewFromInterface create a mapstr instance from the interface Support Input Type: []byte, string, base-type map, struct. If the input value type is []byte or string, then the value must be a valid json. Like: map[string]int will be converted into MapStr Like: struct { TestStr string TestInt int } will be converted into MapStr{"TestStr":"", "TestInt":0}
func NewFromMap ¶
NewFromMap create a new MapStr from map[string]interface{} type
func NewFromStruct ¶
NewFromStruct convert the struct into MapStr , the struct must be taged with 'tagName' .
eg: type targetStruct struct{ Name string `field:"testName"` } will be converted the follow map {"testName":""}
func SetValueToMapStrByTags ¶
func SetValueToMapStrByTags(source interface{}) MapStr
SetValueToMapStrByTags convert a struct to MapStr by tags default tag name is field
func SetValueToMapStrByTagsWithTagName ¶
SetValueToMapStrByTagsWithTagName convert a struct to MapStr by tags
func (MapStr) Different ¶
Different the current value is different from the content of the given data
func (MapStr) MapStrArray ¶
MapStrArray get the MapStr object array
func (MapStr) MarshalJSONInto ¶
MarshalJSONInto convert to the input value
func (MapStr) Merge ¶
Merge merge second into self,if the key is the same then the new value replaces the old value.
func (MapStr) ToMapInterface ¶
ToMapInterface convert to map[string]interface{}
func (MapStr) ToStructByTag ¶
ToStructByTag convert self into a struct with 'tagName'
eg: self := MapStr{"testName":"testvalue"} targetStruct := struct{ Name string `field:"testName"` } After call the function self.ToStructByTag(targetStruct, "field") the targetStruct.Name value will be 'testvalue'