package config import ( "log/slog" "time" ) type Config struct { Server ServerConfig `mapstructure:"server"` DB DBConfig `mapstructure:"db"` DataDir string `mapstructure:"data_dir"` Sync SyncConfig `mapstructure:"sync"` Log LogConfig `mapstructure:"log"` } type ServerConfig struct { Host string `mapstructure:"host"` Port int `mapstructure:"port"` } type DBConfig struct { Path string `mapstructure:"path"` } type SyncConfig struct { Interval string `mapstructure:"interval"` } type LogConfig struct { Level string `mapstructure:"level"` Format string `mapstructure:"format"` } func (l LogConfig) SlogLevel() slog.Level { switch l.Level { case "debug": return slog.LevelDebug case "warn", "warning": return slog.LevelWarn case "error": return slog.LevelError default: return slog.LevelInfo } } func (s SyncConfig) IntervalDuration() time.Duration { d, err := time.ParseDuration(s.Interval) if err != nil || d <= 0 { return time.Hour } return d }