config: use os.UserConfigDir
This commit is contained in:
parent
e1b5ccefb0
commit
9f72034eb3
|
@ -1,19 +1,14 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Path(filename string) (string, error) {
|
func Path(filename string) (string, error) {
|
||||||
configHome := os.Getenv("XDG_CONFIG_HOME")
|
configHome, err := os.UserConfigDir()
|
||||||
if configHome == "" {
|
if err != nil {
|
||||||
home := os.Getenv("HOME")
|
return "", err
|
||||||
if home == "" {
|
|
||||||
return "", errors.New("HOME not set")
|
|
||||||
}
|
|
||||||
configHome = filepath.Join(home, ".config")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p := filepath.Join(configHome, "hydroxide", filename)
|
p := filepath.Join(configHome, "hydroxide", filename)
|
||||||
|
|
Loading…
Reference in New Issue