convertToFloat64 converts any value to float64
(v any)
| 116 | |
| 117 | // convertToFloat64 converts any value to float64 |
| 118 | func convertToFloat64(v any) (float64, error) { |
| 119 | switch val := v.(type) { |
| 120 | case float64: |
| 121 | return val, nil |
| 122 | case int: |
| 123 | return float64(val), nil |
| 124 | case int64: |
| 125 | return float64(val), nil |
| 126 | case string: |
| 127 | return strconv.ParseFloat(val, 64) |
| 128 | default: |
| 129 | return 0, fmt.Errorf("unsupported type: %T", v) |
| 130 | } |
| 131 | } |
no outgoing calls
no test coverage detected