Add blank lines for readability
This commit is contained in:
parent
e08527f9ea
commit
be88f1b82a
1 changed files with 9 additions and 0 deletions
|
@ -14,27 +14,36 @@ type Config struct {
|
|||
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue