new helper method

This commit is contained in:
nquidox 2026-04-03 20:53:29 +03:00
parent ffbd38f69a
commit c1c0e46184

View file

@ -27,13 +27,22 @@ func getEnvSeconds(key string, fallback int) time.Duration {
return time.Duration(fallback) * time.Second
}
func getEnvInt(key string, fallback int) int {
if value, ok := os.LookupEnv(key); ok {
num, err := strconv.Atoi(value)
if err != nil {
return fallback
}
return num
}
return fallback
}
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 fallback
}
return uint(num)
}