Created
May 1, 2023 15:57
-
-
Save kitlabcode/bcaf69f68523166da26458bd725be514 to your computer and use it in GitHub Desktop.
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
| func GetVal(data map[string]any, key string) (result any, found bool) { | |
| for k, v := range data { | |
| if k == key { | |
| return v, true | |
| } else { | |
| switch v.(type) { | |
| case map[string]any: | |
| if result, found = GetVal(v.(map[string]any), key); found { | |
| return | |
| } | |
| } | |
| } | |
| } | |
| return nil, false} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment