Documentation
¶
Index ¶
- func FastestCopyStruct(s, d any)
- func FastestMapToStruct(m any, s any)
- func FastestStructToMap(s any) (m map[string]any)
- func SSKeysStartedWith(m SS, prefix string) []string
- func ToJson(hash map[string]any) string
- func ToMsgp(hash map[string]any) []byte
- type FieldTag
- type IAX
- type IB
- type II
- type IS
- type IX
- type SAX
- type SB
- func (hash SB) IntoJson() (string, bool)
- func (hash SB) IntoJsonPretty() (string, bool)
- func (hash SB) IntoMsgp() ([]byte, bool)
- func (hash SB) KeysConcat(with string) string
- func (hash SB) SortedKeys() []string
- func (hash SB) ToJson() string
- func (hash SB) ToJsonPretty() string
- func (hash SB) ToMsgp() []byte
- type SF
- type SI
- type SS
- func (hash SS) GetFloat(key string) float64
- func (hash SS) GetInt(key string) int64
- func (hash SS) GetStr(key string) string
- func (hash SS) GetUint(key string) uint64
- func (hash SS) Keys() []string
- func (hash SS) KeysConcat(with string) string
- func (hash SS) Merge(src SS)
- func (hash SS) Pretty(sep string) string
- func (hash SS) PrettyFunc(sep string, fun func(string, string) string) string
- func (hash SS) SortedKeys() []string
- func (hash SS) ToJson() string
- func (hash SS) ToMsgp() []byte
- func (hash SS) ToScylla() string
- type SX
- func (hash *SX) FromJson(str string) (ok bool)
- func (json SX) GetAX(key string) []any
- func (json SX) GetBool(key string) bool
- func (json SX) GetFloat(key string) float64
- func (json SX) GetInt(key string) int64
- func (json SX) GetIntArr(key string) []int64
- func (json SX) GetMIB(key string) IB
- func (json SX) GetMSB(key string) SB
- func (json SX) GetMSF(key string) SF
- func (json SX) GetMSI(key string) SI
- func (json SX) GetMSX(key string) SX
- func (json SX) GetStr(key string) string
- func (json SX) GetUint(key string) uint64
- func (hash SX) IntoJson() (string, bool)
- func (hash SX) IntoJsonPretty() (string, bool)
- func (hash SX) IntoMsgp() ([]byte, bool)
- func (hash SX) Keys() []string
- func (hash SX) Pretty(sep string) string
- func (hash SX) Set(key string, val any)
- func (hash SX) SortedKeys() []string
- func (hash SX) ToJson() string
- func (hash SX) ToJsonPretty() string
- func (hash SX) ToMsgp() []byte
- func (m SX) ToStruct(targetStructPtr any)
- type StructMapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FastestCopyStruct ¶
func FastestCopyStruct(s, d any)
FastestCopyStruct target can be struct or map
func FastestMapToStruct ¶
FastestMapToStruct only for exact match of field name and map key
func FastestStructToMap ¶
FastestStructToMap using struct's field name as map key
func SSKeysStartedWith ¶
SSKeysStartedWith retrieve all keys started with
Types ¶
type IB ¶
IB map with int64 key and bool value
func (IB) Keys ¶
Keys get array of int64 keys
m := M.IB{1:true,2:false} m.Keys() // []int64{1, 2}
get all integer keys
func (IB) KeysConcat ¶
KeysConcat get concatenated integer keys
m := M.IB{1: true, 2: false, 3:true, 5:false} m.KeysConcat(`,`) // `1,2,3,5`
type II ¶
II map with int64 key and int64 value
func (II) KeysConcat ¶
KeysConcat get concatenated integer keys
m := M.II{1: 2, 2: 567, 3:6, 5:45} m.KeysConcat(`,`) // `1,2,3,5`
type IX ¶
IX map with int64 key and any value
type SB ¶
SB map with string key and bool value
func (SB) IntoJsonPretty ¶
convert to pretty json string with check
func (SB) KeysConcat ¶
KeysConcat get concatenated string keys
m := M.SB{`tes`:true,`coba`:true,`lah`:true} m.KeysConcat(`,`) // `coba,lah,tes`
func (SB) SortedKeys ¶
SortedKeys get sorted keys
m := M.SS{`tes`:true,`coba`:false,`lah`:false} m.SortedKeys() // []string{`coba`,`lah`,`tes`}
func (SB) ToJsonPretty ¶
ToJsonPretty convert to pretty json string, silently print error if failed
type SS ¶
SS map with string key and string value
func (SS) Keys ¶
Keys get array of string keys
m := M.SS{`satu`:`1`,`dua`:`2`} m.Keys() // []string{"satu", "dua"}
func (SS) KeysConcat ¶
KeysConcat get concatenated string keys
m := M.SS{`tes`:`tes`,`coba`:`saja`,`lah`:`lah`} m.KeysConcat(`,`) // `coba,lah,tes`
func (SS) PrettyFunc ¶
PrettyFunc get pretty printed values with filter values
func (SS) SortedKeys ¶
SortedKeys get sorted keys
m := M.SS{`tes`:`tes`,`coba`:`saja`,`lah`:`lah`} m.SortedKeys() // []string{`coba`,`lah`,`tes`}
type SX ¶
SX map with string key and any value
func (*SX) FromJson ¶
FromJson convert string to map, silently print error if failed doesn't overwrite existing value if json doesn't have the same key returns true if ok
func (SX) GetAX ¶
GetAX get array of anything value from map
m := M.SX{`tes`:[]any{123,`buah`}} m.GetAX(`tes`) // []interface {}{int(123),"buah"}
func (SX) GetBool ¶
GetBool get bool type from map (empty string, 0, `f`, `false` are false, other non empty are considered truthy value) m := M.SX{`test`:234.345,`coba`:`buah`,`angka`:float64(123),`salah`:123}
m.GetBool(`test`) // bool(true) m.GetBool(`coba`) // bool(true) m.GetBool(`angka`) // bool(true) m.GetBool(`salah`) // bool(false)
func (SX) GetFloat ¶
GetFloat get float64 type from map
m := M.SX{`test`:234.345,`coba`:`buah`,`dia`:true,`angka`:23435} m.GetFloat(`test`) // float64(234.345) m.GetFloat(`dia`) // int64(1) m.GetFloat(`coba`) // 0 m.GetFloat(`angka`) // 0
func (SX) GetInt ¶
GetInt get int64 type from map
m := M.SX{`test`:234.345,`coba`:`buah`,`dia`:true,`angka`:int64(23435)} m.GetInt(`test`)) // int64(234) m.GetInt(`dia`)) // int64(1) m.GetInt(`coba`)) // int64(0) m.GetInt(`angka`)) // int64(23435)
func (SX) GetIntArr ¶
GetIntArr get array int64 value from map
m := M.SX{`tes`:[]int64{123,234}} m.GetIntArr(`tes`)) // []int64{123, 234}
func (SX) GetMIB ¶
GetMIB get map string int64 value from map
m := M.SX{`tes`:M.SB{`satu`:true,`2`:false}} m.GetMSB(`tes`) // M.SB{"satu":true, "2":false}
func (SX) GetMSB ¶
GetMSB get map string bool value from map
m := M.SX{`tes`:M.SB{`1`:true,`2`:false}} m.GetMSB(`tes`) // M.SB{"1":true, "2":false}
func (SX) GetMSF ¶
GetMSF get map string float64 value from map
m := M.SX{`tes`:M.SF{`satu`:32.45,`2`:12}} m.GetMSF(`tes`) // M.SF{"satu":32.45, "2":12}
func (SX) GetMSI ¶
GetMSI get map string int64 value from map
m := M.SX{`tes`:M.SF{`satu`:32,`2`:12}} m.GetMSI(`tes`) // M.SF{"satu":32, "2":12}
func (SX) GetMSX ¶
GetMSX get map string anything value from map
m := M.SX{`tes`:M.SX{`satu`:234.345,`dua`:`huruf`,`tiga`:123}} m.GetMSX(`tes`) // M.SX{"tiga": int(123),"satu": float64(234.345),"dua": "huruf"}
func (SX) GetStr ¶
GetStr get string type from map
m := M.SX{`test`:234.345,`coba`:`buah`,`angka`:int64(123)} m.GetStr(`test`) // `234.345` m.GetStr(`coba`) // `buah` m.GetStr(`angka`) // `123`
func (SX) GetUint ¶
GetUint get uint type from map
m := M.SX{`test`:234.345,`coba`:`buah`,`dia`:true,`angka`:int64(23435)} m.GetInt(`test`)) // int64(234) m.GetInt(`dia`)) // int64(1) m.GetInt(`coba`)) // int64(0) m.GetInt(`angka`)) // int64(23435)
func (SX) IntoJsonPretty ¶
IntoJsonPretty convert to pretty json string with check
func (SX) Keys ¶
Keys get array of string keys
m := M.SS{`satu`:`1`,`dua`:`2`} m.Keys() // []string{"satu", "dua"}
func (SX) SortedKeys ¶
SortedKeys get sorted keys
m := M.SX{`tes`:1,`coba`:12.4,`lah`:false} m.SortedKeys() // []string{`coba`,`lah`,`tes`}
func (SX) ToJsonPretty ¶
ToJsonPretty convert to pretty json string, silently print error if failed
type StructMapper ¶
type StructMapper struct { StructName string Offset2key map[uintptr]string Key2offset map[string]uintptr // contains filtered or unexported fields }
func ParseStruct ¶
func ParseStruct(s any, tag FieldTag) (sm *StructMapper)
ParseStruct convert struct to structMapper
func StructMap ¶
func StructMap(structPtr any) *StructMapper
StructMap get or create a struct mapper
func (*StructMapper) MapToStruct ¶
func (sm *StructMapper) MapToStruct(m SX, s any)
func (*StructMapper) StructToMap ¶
func (sm *StructMapper) StructToMap(s any) (m SX)