smtp and ui

This commit is contained in:
mats committed 2026-08-22 11:05:16 +02:00
1 parent 93cfa123e4
commit a7d8b6107a
1 file changed
+15
+15
View File
@@ -63,6 +63,21 @@ func EnvFloat32(key string, def float32, valid func(float32) bool) float32 {
return float32(f) return float32(f)
} }
// EnvBool parses key as a boolean ("1", "true", "yes", "on" / "0", "false",
// ...), accepting the same literals strconv.ParseBool accepts.
func EnvBool(key string, def bool) bool {
v, ok := os.LookupEnv(key)
if !ok || v == "" {
return def
}
b, err := strconv.ParseBool(v)
if err != nil {
log.Printf("invalid %s %q, using %t", key, v, def)
return def
}
return b
}
// EnvDuration parses key as a time.Duration (e.g. "2m", "30s"). // EnvDuration parses key as a time.Duration (e.g. "2m", "30s").
func EnvDuration(key string, def time.Duration) time.Duration { func EnvDuration(key string, def time.Duration) time.Duration {
v, ok := os.LookupEnv(key) v, ok := os.LookupEnv(key)