From 2b949a4a61762d810e114d3442ea2a50aa72f5af Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Fri, 3 Jan 2025 16:49:19 +0100 Subject: [PATCH] Check the XDG_CONFIG_HOME env variable before calling os.UserConfigDir --- app/config.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/config.go b/app/config.go index 64feded..88100fe 100644 --- a/app/config.go +++ b/app/config.go @@ -26,9 +26,13 @@ func defaultConfig() *Config { } func defaultConfigFile() (string, error) { - configDir, err := os.UserConfigDir() - if err != nil { - return "", err + configDir := os.Getenv("XDG_CONFIG_HOME") + if configDir == "" { + dir, err := os.UserConfigDir() + if err != nil { + return "", err + } + configDir = dir } return filepath.Join(configDir, "lazysql", "config.toml"), nil }