package config import ( "log" "os" "strconv" ) func Env(name string, out any, def string) { raw := os.Getenv(name) if raw == "" { raw = def log.Printf("No \"%s\" provided, defaulting to \"%s\".", name, def) } switch value := out.(type) { case *int: i, err := strconv.ParseInt(raw, 10, 64) if err != nil { log.Printf("\"%s\" is not a number (\"%s\").", name, raw) return } *value = int(i) case *bool: switch raw { case "true", "TRUE", "1": *value = true case "false", "FALSE", "0": *value = false } case *string: *value = raw } }