From 1e4a1177ff3b9e97da662db921467aff3f3f3e65 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Mon, 8 Apr 2024 11:40:32 +0200 Subject: [PATCH] chore: initialize config path cache correctly --- src/config/config.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/config/config.go b/src/config/config.go index 9edc5e8..1acf7f6 100644 --- a/src/config/config.go +++ b/src/config/config.go @@ -34,17 +34,17 @@ var ( ) func LoadConfig(configPath string) (*Aliae, error) { - configPath = resolveConfigPath(configPath) + configPathCache = resolveConfigPath(configPath) - if strings.HasPrefix(configPath, "http://") || strings.HasPrefix(configPath, "https://") { - return getRemoteConfig(configPath) + if strings.HasPrefix(configPathCache, "http://") || strings.HasPrefix(configPathCache, "https://") { + return getRemoteConfig(configPathCache) } - if filepath, err := os.Stat(configPath); os.IsNotExist(err) || filepath.IsDir() { - return nil, fmt.Errorf("Config file not found: %s", configPath) + if filepath, err := os.Stat(configPathCache); os.IsNotExist(err) || filepath.IsDir() { + return nil, fmt.Errorf("Config file not found: %s", configPathCache) } - data, _ := os.ReadFile(configPath) + data, _ := os.ReadFile(configPathCache) return parseConfig(data) } @@ -73,8 +73,6 @@ func resolveConfigPath(configPath string) string { configPath = path.Join(home(), ".aliae.yaml") } - configPathCache = configPath - return configPath }