You've already forked reloading-manager
Reviewed-on: rrise/reloading-manager#26 Co-authored-by: Ron Rise <ron@siteworxpro.com> Co-committed-by: Ron Rise <ron@siteworxpro.com>
31 lines
486 B
Go
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
|
|
}
|