fix(conf): fix detection of configuration file not found error
All checks were successful
Go Project Action / Spell-check and test go project (push) Successful in 1m2s
Release Go Application / Release go project (release) Successful in 34s
Go Project Action / Spell-check and test go project (release) Successful in 29s

This commit is contained in:
2024-10-06 11:33:29 +02:00
parent 62b49cf36c
commit ba8e654b90
3 changed files with 19 additions and 6 deletions

View File

@@ -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))
}
}
}