亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

將接口轉換為其對應的地圖

將接口轉換為其對應的地圖

Go
料青山看我應如是 2021-09-13 10:28:10
例如,如果我有一個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 關注
  • 212 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號