Skip to content

Commit

Permalink
Check the XDG_CONFIG_HOME env variable before calling os.UserConfigDir
Browse files Browse the repository at this point in the history
  • Loading branch information
svanharmelen committed Jan 3, 2025
1 parent 35fbda1 commit d0acf68
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit d0acf68

Please sign in to comment.