Skip to content

Instantly share code, notes, and snippets.

@dxavx
Last active May 28, 2021 20:59
Show Gist options
  • Select an option

  • Save dxavx/e4da38a7c88a2fc4ed54459e8cc81729 to your computer and use it in GitHub Desktop.

Select an option

Save dxavx/e4da38a7c88a2fc4ed54459e8cc81729 to your computer and use it in GitHub Desktop.
json swtch type
kv := map[string]interface{}{}
kv["A"] = 1
kv["B"] = "XXX"
kv["C"] = true
for k, v := range kv {
switch v.(type) {
case int:
fmt.Println(k, "INT ", v)
case string:
fmt.Println(k, "STRING", v)
case bool:
fmt.Println(k, "BOOL", v)
case uint64:
fmt.Println(k, "UUINT64", v)
case uint:
fmt.Println(k, "UUINT", v)
}
}
@dxavx
Copy link
Author

dxavx commented May 28, 2021

JSON

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment