Iterating over all the keys of a map

前端 未结 4 2110
借酒劲吻你
借酒劲吻你 2020-12-12 11:33

Is there a way to get a list of all the keys in a Go language map? The number of elements is given by len(), but if I have a map like:

m := map         


        
4条回答
  •  无人及你
    2020-12-12 12:28

    This is also an option

     for key, element := range myMap{
        fmt.Println("Key:", key, "Element:", element)
     }
    

提交回复
热议问题