helper added

This commit is contained in:
nquidox 2026-02-21 16:58:20 +03:00
parent 71e2e1b7b1
commit 81213c67f8

View file

@ -26,3 +26,16 @@ func getEnvSeconds(key string, fallback int) time.Duration {
} }
return time.Duration(fallback) * time.Second return time.Duration(fallback) * time.Second
} }
func getEnvUint(key string, fallback uint) uint {
var def uint = 100
if value, ok := os.LookupEnv(key); ok {
num, err := strconv.ParseUint(value, 10, 64)
if err != nil {
log.Printf("Error converting %v to uint, using default value - %v", key, def)
return def
}
return uint(num)
}
return fallback
}