helper added
This commit is contained in:
parent
71e2e1b7b1
commit
81213c67f8
1 changed files with 13 additions and 0 deletions
|
|
@ -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
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue