From 0f4c88be394756e97084e73b8562142be63cc46b Mon Sep 17 00:00:00 2001 From: Ingo Oppermann Date: Thu, 7 Sep 2023 16:23:15 +0200 Subject: [PATCH] Fix default search paths for config file --- config/store/location.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/config/store/location.go b/config/store/location.go index e073a0c8..627b3d7e 100644 --- a/config/store/location.go +++ b/config/store/location.go @@ -7,11 +7,11 @@ import ( // Location returns the path to the config file. If no path is provided, // different standard location will be probed: -// - os.UserConfigDir() + /datarhei-core/config.js -// - os.UserHomeDir() + /.config/datarhei-core/config.js -// - ./config/config.js +// - os.UserConfigDir() + /datarhei-core/config.json +// - os.UserHomeDir() + /.config/datarhei-core/config.json +// - ./config/config.json // If the config doesn't exist in none of these locations, it will be assumed -// at ./config/config.js +// at ./config/config.json func Location(filepath string) string { configfile := filepath if len(configfile) != 0 { @@ -22,13 +22,16 @@ func Location(filepath string) string { if dir, err := os.UserConfigDir(); err == nil { locations = append(locations, dir+"/datarhei-core/config.js") + locations = append(locations, dir+"/datarhei-core/config.json") } if dir, err := os.UserHomeDir(); err == nil { locations = append(locations, dir+"/.config/datarhei-core/config.js") + locations = append(locations, dir+"/.config/datarhei-core/config.json") } locations = append(locations, "./config/config.js") + locations = append(locations, "./config/config.json") for _, path := range locations { info, err := os.Stat(path) @@ -44,7 +47,7 @@ func Location(filepath string) string { } if len(configfile) == 0 { - configfile = "./config/config.js" + configfile = "./config/config.json" } os.MkdirAll(path.Dir(configfile), 0740)