(in interface{})
| 283 | } |
| 284 | |
| 285 | func InterfaceToInt64Downcast(in interface{}) (int64, bool) { |
| 286 | var ok bool |
| 287 | if in, ok = JSONNumberToIntOrFloat(in); !ok { |
| 288 | return 0, false |
| 289 | } |
| 290 | |
| 291 | switch casted := in.(type) { |
| 292 | case int8: |
| 293 | return int64(casted), true |
| 294 | case int16: |
| 295 | return int64(casted), true |
| 296 | case int32: |
| 297 | return int64(casted), true |
| 298 | case int: |
| 299 | return int64(casted), true |
| 300 | case int64: |
| 301 | return casted, true |
| 302 | case float32: |
| 303 | if val := int64(casted); float32(val) == casted { |
| 304 | return val, true |
| 305 | } |
| 306 | case float64: |
| 307 | if val := int64(casted); float64(val) == casted { |
| 308 | return val, true |
| 309 | } |
| 310 | } |
| 311 | return 0, false |
| 312 | } |
| 313 | |
| 314 | // InterfaceToFloat32 will convert any int or float type |
| 315 | func InterfaceToFloat32(in interface{}) (float32, bool) { |
nothing calls this directly
no test coverage detected