diff --git a/cmd/dweb/main.go b/cmd/dweb/main.go index 1259a3d..dec8abd 100644 --- a/cmd/dweb/main.go +++ b/cmd/dweb/main.go @@ -9,6 +9,7 @@ import ( "os" "os/signal" "path/filepath" + "strconv" "strings" "syscall" "time" @@ -56,21 +57,15 @@ func envBool(k string) bool { v := strings.ToLower(os.Getenv(k)) return v == "1" || v == "true" || v == "yes" } + func envInt64(k string, def int64) int64 { if v := os.Getenv(k); v != "" { - var x int64 - _, _ = fmtSscanf(v, &x) - return x + if x, err := strconv.ParseInt(v, 10, 64); err == nil { + return x + } } return def } -func fmtSscanf(s string, p *int64) (int, error) { return fmtSscanfImpl(s, p) } - -// tiny wrapper to avoid importing fmt at top-level; keeps imports tidy -func fmtSscanfImpl(s string, p *int64) (int, error) { return fmtSscanfReal(s, p) } - -//go:linkname fmtSscanfReal fmt.Sscanf -func fmtSscanfReal(s string, p *int64) (int, error) func loadConfig() Config { cfg := Config{