Skip to content

Commit 0924e19

Browse files
appleboyclaude
andcommitted
fix(config): fail fast on config parse errors and fix misleading comment
- Fix misleading comment about config file search behavior - Return error on config parse/permission failures instead of silently falling back to defaults; only ignore ConfigFileNotFoundError Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent cd29bca commit 0924e19

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

config/config.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,14 +326,19 @@ func LoadConf(confPath ...string) (*ConfYaml, error) {
326326
return loadConfigFromViper(v)
327327
}
328328

329-
// Search config in home directory with name ".gorush" (without extension).
329+
// Search for config.{yaml,yml,json,...} in standard directories.
330330
v.AddConfigPath("/etc/gorush/")
331331
v.AddConfigPath("$HOME/.gorush")
332332
v.AddConfigPath(".")
333333
v.SetConfigName("config")
334334

335335
// If a config file is found, read it in.
336-
if err := v.ReadInConfig(); err == nil {
336+
if err := v.ReadInConfig(); err != nil {
337+
// Only ignore "config file not found" — fail on parse/permission errors
338+
if _, ok := err.(viper.ConfigFileNotFoundError); !ok {
339+
return nil, fmt.Errorf("failed to read config: %w", err)
340+
}
341+
} else {
337342
log.Println("Using config file:", v.ConfigFileUsed())
338343
}
339344

0 commit comments

Comments
 (0)