fix(config): merge default config

This commit is contained in:
ayn2op 2024-09-22 02:13:21 +05:30
parent e9ba80b948
commit 3999756947

View file

@ -44,8 +44,10 @@ func defaultConfig() *Config {
func Load() (*Config, error) {
path := filepath.Join(constants.ConfigDirPath, "config.toml")
f, err := os.Open(path)
cfg := defaultConfig()
if os.IsNotExist(err) {
return defaultConfig(), nil
return cfg, nil
}
if err != nil {
@ -53,7 +55,6 @@ func Load() (*Config, error) {
}
defer f.Close()
var cfg *Config
if _, err := toml.NewDecoder(f).Decode(&cfg); err != nil {
return nil, err
}