例如,如果我有一個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 回答
- 0 關注
- 212 瀏覽
添加回答
舉報
0/150
提交
取消