var data = make([]map[string]interface{}, 0)
var area = make(map[string]interface{})
maps_temp := []map[string]interface{}{{"id":1, "value":"a"},{"id":2, "value":"b"},{"id":3, "value":"c"}}
for _, value := range maps_temp {
area["id"] = value["id"]
area["value"] = value["value"]
data = append(data, area)
}
fmt.Println("data:",data)
The result is
data: [map[id:3 value:c] map[id:3 value:c] map[id:3 value:c]]
expected result is :
data: [map[id:1 value:a] map[id:2 value:b] map[id:3 value:c]]
有疑问加站长微信联系(非本文作者)