cvt
GitHub切换暗/亮/自动模式切换暗/亮/自动模式切换暗/亮/自动模式返回首页

Map

StringMapE

  • Map
// expect: map[string]interface{}{"111": "cvt", "222": 3.21}
cvt.StringMapE(map[interface{}]interface{}{111: "cvt", "222": 3.21})
  • Struct
// expect: map[string]interface{}{"Name": "cvt", "Age": 3}
cvt.StringMapE(struct {
    Name string
    Age  int
}{"cvt", 3})
  • JSON
// expect: map[string]interface{}{"name": "cvt", "age": 3.21}
cvt.StringMapE(`{"name":"cvt","age":3.21}`)

IntMapE

  • Map
// expect: map[int]interface{}{111: "cvt", 222: 3.21}
cvt.IntMapE(map[interface{}]interface{}{111: "cvt", "222": 3.21})
  • JSON
// expect: map[int]interface{}{1: "cvt", 2: 3.21}
cvt.IntMapE(`{"1":"cvt","2":3.21}`)

更多示例请看单元测试:map_test.go