map[string]interface如何转成map[string]string

chenzy · · 1429 次点击
fenglangjuxu
出售域名 http://letsgo.xin
```golang func MapInterface2String(inputData map[string]interface{}) map[string]string { outputData := map[string]string{} for key, value := range inputData { switch value.(type) { case string: outputData[key] = value.(string) case int: tmp := value.(int) outputData[key] = Int2Str(tmp) case int64: tmp := value.(int64) outputData[key] = Int642Str(tmp) } } return outputData } ```
#2
更多评论
这样? ```go student["Name"].(string) ```
#1