Last active
May 28, 2021 20:59
-
-
Save dxavx/e4da38a7c88a2fc4ed54459e8cc81729 to your computer and use it in GitHub Desktop.
json swtch type
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JSON