From b8572ea7120e505e149006c28f3bcff3a8fdfb34 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Thu, 11 Jan 2024 23:23:22 -0500 Subject: [PATCH] fix: use logger and return errors --- config/config.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/config.go b/config/config.go index c952a86..2007855 100644 --- a/config/config.go +++ b/config/config.go @@ -2,7 +2,6 @@ package config import ( "errors" - "fmt" "github.com/spf13/viper" "go.uber.org/zap" ) @@ -15,7 +14,7 @@ var ( } ) -func Init(logger *zap.Logger) { +func Init(logger *zap.Logger) error { viper.SetConfigName("config") viper.SetConfigType("yaml") @@ -29,10 +28,11 @@ func Init(logger *zap.Logger) { err := viper.ReadInConfig() if err != nil { if errors.As(err, &viper.ConfigFileNotFoundError{}) { - // Config file not found, this is not an error. - fmt.Println("Config file not found, using default settings.") - } else { - logger.Fatal("Fatal error config file", zap.Error(err)) + logger.Info("Config file not found, using default settings.") + return nil } + return err } + + return nil }