golang map getkeys

golang 获取map的keys

package main

import "fmt"
import "reflect"

func main() {
    abc := map[string]int{
        "a": 1,
        "b": 2,
        "c": 3,
    }

    keys := reflect.ValueOf(abc).MapKeys()

    fmt.Println(keys) // [a b c]
}

 

posted on 2016-11-07 13:51  iokde.com  阅读(2133)  评论(0编辑  收藏  举报

导航