如下定义:
mapStr := make(map[string]string)
只能储存string类型的value。
如下定义:
mapInt := make(map[string]int)
只能保存int类型的value。
如下定义:
mapInterface := make(map[string]interface{})
可以保存string、int等不同类型的value。
mu := make([]map[string]interface{},0) a1 := map[string]interface{} {"id": 1, "parentId": 0, "createTime": "2020-02-02T06:50:36.000+0000", "title": "商品", "level": 0, "sort": 0, "name": "pms", "icon": "product", "hidden": 0} a2 := map[string]interface{} {"id": 2, "parentId": 1, "createTime": "2020-02-02T06:51:50.000+0000", "title": "商品列表", "level": 1, "sort": 0, "name": "product", "icon": "product-list", "hidden": 0} mu = append(mu, a1) mu = append(mu, a2)
结束!