package settings import ( "io/fs" "os" "github.com/pelletier/go-toml" ) type Settings struct { API API DailyScripture DailyScripture `toml:"daily_scripture"` System System Translations Translations } type API struct { BaseURL string `toml:"base_url"` Schedule string Rotation string User string } type DailyScripture struct { UserSubmitted bool `toml:"user_submitted"` } type System struct { TimeZone string `toml:"timezone"` } type Translations struct { BaseDir string `toml:"basedir"` Active []string `toml:"active"` } func LoadSettings(name string) (*Settings, error) { conf := &Settings{} buf, err := os.ReadFile(name) if err != nil { if _, ok := err.(*fs.PathError); ok { return nil, ErrSettingsNotFound.Do(err) } return nil, ErrReadingSettings.Do(err) } err = toml.Unmarshal(buf, conf) if err != nil { return nil, ErrReadingSettings.Do(err) } return conf, nil }