From 925bf97fccefec0fb06ff8e4993bd699b533fa35 Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 26 Nov 2024 09:51:18 +1100 Subject: [PATCH] fix: if config already exists, return it --- config/config.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/config.go b/config/config.go index 6f87143..67a36b0 100644 --- a/config/config.go +++ b/config/config.go @@ -79,6 +79,10 @@ func LoadConfig() (Config, error) { if _, ok := err.(viper.ConfigFileNotFoundError); ok { // Config file not found; create it if err := CreateDefaultConfig(); err != nil { + // if the file already exists - return it, otherwise throw an error + if _, err := os.Stat(getConfigPath()); err == nil { + return LoadConfig() + } return Config{}, fmt.Errorf("failed to create default config: %w", err) } } else {