config: use os.UserConfigDir

This commit is contained in:
Simon Ser 2022-05-24 21:20:13 +02:00
parent e1b5ccefb0
commit 9f72034eb3
1 changed files with 3 additions and 8 deletions

View File

@ -1,19 +1,14 @@
package config
import (
"errors"
"os"
"path/filepath"
)
func Path(filename string) (string, error) {
configHome := os.Getenv("XDG_CONFIG_HOME")
if configHome == "" {
home := os.Getenv("HOME")
if home == "" {
return "", errors.New("HOME not set")
}
configHome = filepath.Join(home, ".config")
configHome, err := os.UserConfigDir()
if err != nil {
return "", err
}
p := filepath.Join(configHome, "hydroxide", filename)