Spaces:
Running
Running
package mapx | |
import ( | |
"fmt" | |
"testing" | |
) | |
func TestMapx(t *testing.T) { | |
mapx := Mapx{ | |
"string": "abc", | |
"int": 1234, | |
"float": 12.34, | |
"slice": []any{ | |
"a", | |
map[string]any{ | |
"aa": map[string]interface{}{ | |
"qwe": 123, | |
}, | |
}, | |
"c", | |
}, | |
"map": map[string]any{ | |
"map": map[string]any{ | |
"bool": true, | |
"aa": map[string]interface{}{ | |
"qwe": 123, | |
}, | |
}, | |
}, | |
"m2": Mapx{ | |
//"a": model.PayOrder{OrderNo: "1234"}, | |
//"b": &model.PayOrder{OrderNo: "123444"}, | |
}, | |
} | |
//v := mapx.ListByIDs("map.map.aa.qwe") | |
//v := mapx.ListByIDs("slice.[1].aa.qwe") | |
v := mapx.Get("m2.b.OrderNo") | |
//v := mapx.ListByIDs("int") | |
//vv := v.(int) | |
fmt.Printf("type:%T value:%v\n", v, v) | |
} | |