package config import ( "fmt" "os" "path/filepath" "gopkg.in/yaml.v3" ) type Config struct { Depth string `yaml:"depth"` Directories []string `yaml:"directories"` } func getConfigPath() (string, error) { home, err := os.UserHomeDir() if err != nil { return "", err } return filepath.Join(home, ".config", "git-repo-updater", "config.yaml"), nil } func Load() (Config, error) { path, err := getConfigPath() if err != nil { return Config{}, err } data, err := os.ReadFile(path) if err != nil { return Config{}, fmt.Errorf("read config: %w", err) } var cfg Config if err := yaml.Unmarshal(data, &cfg); err != nil { return Config{}, fmt.Errorf("parse config: %w", err) } if len(cfg.Directories) == 0 { return Config{}, fmt.Errorf("no directories configured") } return cfg, nil }