Files
reloading-manager/backend/handlers/numbers.go
2025-04-18 17:30:11 -04:00

31 lines
486 B
Go

package handlers
import "strconv"
func ParseFloat32(v string) (float32, error) {
fl, err := strconv.ParseFloat(v, 32)
if err != nil {
return 0, err
}
return float32(fl), nil
}
func ParseInt32WithDefault(s string, def int32) int32 {
sInt, err := strconv.ParseInt(s, 10, 32)
if err != nil {
return def
}
return int32(sInt)
}
func ParseInt64OrDefault(s string, def int64) int64 {
sInt, err := strconv.ParseInt(s, 10, 64)
if err != nil {
return def
}
return sInt
}