例如,如果我有一个interface{}最初是 amap[string]map[int64][]int64或任何其他类型地图的值,如何获取地图的键类型?或更准确地说,如何将其转换为map[theKeyType]interface{}?func Transverse(any interface{}) string { res := `` switch any.(type) { case string: return `` case []byte: return `` case int, int64, int32: return `` case float32, float64: return `` case bool: return `` case map[int64]interface{}: return `` case map[string]interface{}: return `` case []interface{}: return `` default: kind := reflect.TypeOf(any).Kind() switch kind { case reflect.Map: // how to convert it to map[keyType]interface{} ? } return `` // handle other type } return ``}
1 回答
- 1 回答
- 0 关注
- 189 浏览
添加回答
举报
0/150
提交
取消