This commit is contained in:
Florian Baumann 2023-04-20 11:04:53 +02:00
parent c106a01a28
commit 4a1147b1af

View File

@ -217,3 +217,26 @@ func filterForDigits(str string) int {
s, _ := strconv.Atoi(numStr)
return s
}
func getFloat64(unknown interface{}) (float64, error) {
switch i := unknown.(type) {
case float64:
return i, nil
case float32:
return float64(i), nil
case int64:
return float64(i), nil
case int32:
return float64(i), nil
case int:
return float64(i), nil
case uint64:
return float64(i), nil
case uint32:
return float64(i), nil
case uint:
return float64(i), nil
default:
return math.NaN(), errors.New("Non-numeric type could not be converted to float")
}
}