Skip to content

Instantly share code, notes, and snippets.

@kitlabcode
Created May 1, 2023 15:57
Show Gist options
  • Select an option

  • Save kitlabcode/bcaf69f68523166da26458bd725be514 to your computer and use it in GitHub Desktop.

Select an option

Save kitlabcode/bcaf69f68523166da26458bd725be514 to your computer and use it in GitHub Desktop.
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