GetValueWithKey returns the value of the key in the data.
(data map[string]any, key string)
| 5 | |
| 6 | // GetValueWithKey returns the value of the key in the data. |
| 7 | func GetValueWithKey(data map[string]any, key string) any { |
| 8 | keys := strings.Split(key, ".") |
| 9 | value := data[keys[0]] |
| 10 | |
| 11 | if len(keys) > 1 { |
| 12 | if subData, ok := value.(map[string]any); ok { |
| 13 | return GetValueWithKey(subData, strings.Join(keys[1:], ".")) |
| 14 | } |
| 15 | return nil |
| 16 | } |
| 17 | |
| 18 | return value |
| 19 | } |