fix(conf): fix detection of configuration file not found error
This commit is contained in:
7
main.go
7
main.go
@@ -1,7 +1,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
@@ -24,8 +23,10 @@ func loadConfig() {
|
||||
viper.SetConfigType("yml")
|
||||
viper.AddConfigPath("$HOME/.config/serve")
|
||||
viper.AddConfigPath(".")
|
||||
if err := viper.ReadInConfig(); err != nil && !errors.Is(err, viper.ConfigFileNotFoundError{}) {
|
||||
panic(fmt.Errorf("fatal error config file: %w", err))
|
||||
if err := viper.ReadInConfig(); err != nil {
|
||||
if _, ok := err.(viper.ConfigFileNotFoundError); !ok {
|
||||
panic(fmt.Errorf("fatal error config file: %w", err))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user