go 修改map的索引
categories := [{"id":3,"name":"golang"},{"id":5,"name":"php"},{"id":7,"name":"java"}]
categoryArray := make(map[int]interface{}) for k, val := range categories { categoryArray[val.id] = categories[k] } fmt.Println(categoryArray[5])
categories := [{"id":3,"name":"golang"},{"id":5,"name":"php"},{"id":7,"name":"java"}]
categoryArray := make(map[int]interface{}) for k, val := range categories { categoryArray[val.id] = categories[k] } fmt.Println(categoryArray[5])