Skip to content

Commit

Permalink
Use the config dir returned by os.UserConfigDir()
Browse files Browse the repository at this point in the history
  • Loading branch information
svanharmelen committed Dec 30, 2024
1 parent e770cbc commit cbec63a
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions app/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ func defaultConfig() *Config {
}

func LoadConfig() error {
file, err := os.ReadFile(filepath.Join(os.Getenv("HOME"), ".config", "lazysql", "config.toml"))
configDir, err := os.UserHomeDir()
if err != nil {
return err
}
file, err := os.ReadFile(filepath.Join(configDir, "lazysql", "config.toml"))
if err != nil {
return err
}
Expand All @@ -33,11 +37,14 @@ func LoadConfig() error {
func (c *Config) SaveConnections(connections []models.Connection) error {
c.Connections = connections

directoriesPath := filepath.Join(os.Getenv("HOME"), ".config", "lazysql")
configDir, err := os.UserHomeDir()
if err != nil {
return err
}
directoriesPath := filepath.Join(configDir, "lazysql")
configFilePath := filepath.Join(directoriesPath, "config.toml")

err := os.MkdirAll(directoriesPath, 0o755)
if err != nil {
if err = os.MkdirAll(directoriesPath, 0o755); err != nil {
return err
}

Expand Down

0 comments on commit cbec63a

Please sign in to comment.