Skip to content

Commit b49e623

Browse files
committed
main: invert bool fix in readConfig
Thanks @replaceafill for noticing it!
1 parent 5a662fa commit b49e623

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

main.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ func main() {
9595
}
9696

9797
if configFileFound {
98-
logger.Info("Configuration file not found.")
99-
} else {
10098
logger.Info("Configuration file loaded.", "path", v.ConfigFileUsed())
99+
} else {
100+
logger.Info("Configuration file not found.")
101101
}
102102

103103
ctx, cancel := context.WithCancel(context.Background())
@@ -328,8 +328,11 @@ func readConfig(v *viper.Viper, config *configuration, configFile string) (found
328328
}
329329

330330
err = v.ReadInConfig()
331-
_, found = err.(viper.ConfigFileNotFoundError)
332-
if err != nil && !found {
331+
_, ok := err.(viper.ConfigFileNotFoundError)
332+
if !ok {
333+
found = true
334+
}
335+
if found && err != nil {
333336
return found, fmt.Errorf("Failed to read configuration file: %w", err)
334337
}
335338

0 commit comments

Comments
 (0)