getInt retrieves an integer value from a map, returning a fallback value if not found or not a number.
(m map[string]interface{}, key string, fallback int)
| 286 | |
| 287 | // getInt retrieves an integer value from a map, returning a fallback value if not found or not a number. |
| 288 | func getInt(m map[string]interface{}, key string, fallback int) int { |
| 289 | if v, ok := m[key]; ok { |
| 290 | switch n := v.(type) { |
| 291 | case float64: |
| 292 | return int(n) |
| 293 | case int: |
| 294 | return n |
| 295 | } |
| 296 | } |
| 297 | return fallback |
| 298 | } |
no outgoing calls
no test coverage detected