package config import ( "os" "time" ) type Config struct { Addr string DBPath string ArchiveAfter time.Duration } func Load() Config { addr := os.Getenv("TERDUT_ADDR") if addr == "" { addr = ":8080" } dbPath := os.Getenv("TERDUT_DB_PATH") if dbPath == "" { dbPath = "terdut.db" } archiveAfter := 7 * 24 * time.Hour if s := os.Getenv("TERDUT_ARCHIVE_AFTER"); s != "" { if d, err := time.ParseDuration(s); err == nil { archiveAfter = d } } return Config{Addr: addr, DBPath: dbPath, ArchiveAfter: archiveAfter} }