From ca0e4bc3abf36b80fd8bc8dcec7d96acaac8ed30 Mon Sep 17 00:00:00 2001 From: Ravi Suhag Date: Tue, 26 Nov 2024 14:43:38 -0600 Subject: [PATCH] fix: fix pointer issue in config --- config/config.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/config.go b/config/config.go index e9f887c..a149fd6 100644 --- a/config/config.go +++ b/config/config.go @@ -15,19 +15,19 @@ import ( "github.com/spf13/viper" ) -// ConfigFileNotFoundError indicates that the configuration file was not found. +// FileNotFoundError indicates that the configuration file was not found. // In this case, Viper will attempt to load configurations from environment variables or defaults. -type ConfigFileNotFoundError struct { +type FileNotFoundError struct { Err error } // Error returns the error message for ConfigFileNotFoundError. -func (e ConfigFileNotFoundError) Error() string { +func (e FileNotFoundError) Error() string { return fmt.Sprintf("config file not found, falling back to environment and defaults: %v", e.Err) } // Unwrap provides compatibility for error unwrapping. -func (e *ConfigFileNotFoundError) Unwrap() error { +func (e FileNotFoundError) Unwrap() error { return e.Err } @@ -140,7 +140,7 @@ func (l *Loader) Load(config interface{}) error { if err := l.viperInstance.ReadInConfig(); err != nil { var pathErr *fs.PathError if errors.As(err, &pathErr) || errors.As(err, &viper.ConfigFileNotFoundError{}) { - return ConfigFileNotFoundError{Err: err} + return FileNotFoundError{Err: err} } return fmt.Errorf("failed to read config file: %w", err) }