MCPcopy Create free account
hub / github.com/cortexproject/cortex / convertToFloat64

Function convertToFloat64

pkg/overrides/limits.go:118–131  ·  view source on GitHub ↗

convertToFloat64 converts any value to float64

(v any)

Source from the content-addressed store, hash-verified

116
117// convertToFloat64 converts any value to float64
118func 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}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected