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])

 

 

 

posted @ 2022-07-21 18:11  Func~  阅读(52)  评论(0编辑  收藏  举报