package main import ( "errors" "fmt" "atlas9.dev/c/mail/mail_ses" "github.com/BurntSushi/toml" ) type Config struct { Server struct { Port int Host string BaseURL string } Database struct { Path string } Session struct { LifetimeHours int } OAuth struct { Google OAuthProviderConfig Apple OAuthProviderConfig GitHub OAuthProviderConfig } Mail mail_ses.Config } type OAuthProviderConfig struct { ClientID string ClientSecret string RedirectURL string } func loadConfig(path string) (*Config, error) { var config Config if _, err := toml.DecodeFile(path, &config); err != nil { return nil, fmt.Errorf("failed to decode config: %w", err) } if err := config.validate(); err != nil { return nil, err } return &config, nil } func (c *Config) validate() error { var errs []error if c.Server.BaseURL == "" { errs = append(errs, fmt.Errorf("Server.BaseURL is required")) } return errors.Join(errs...) }