forked from shibukawa/configdir
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig_xdg.go
34 lines (29 loc) · 809 Bytes
/
config_xdg.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// +build !windows,!darwin
package configdir
import (
"os"
"path/filepath"
"strings"
)
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
var hasVendorName = true
var systemSettingFolders []string
var globalSettingFolder string
var cacheFolder string
func init() {
if os.Getenv("XDG_CONFIG_HOME") != "" {
globalSettingFolder = os.Getenv("XDG_CONFIG_HOME")
} else {
globalSettingFolder = filepath.Join(os.Getenv("HOME"), ".config")
}
if os.Getenv("XDG_CONFIG_DIRS") != "" {
systemSettingFolders = strings.Split(os.Getenv("XDG_CONFIG_DIRS"), ":")
} else {
systemSettingFolders = []string{"/etc/xdg"}
}
if os.Getenv("XDG_CACHE_HOME") != "" {
cacheFolder = os.Getenv("XDG_CACHE_HOME")
} else {
cacheFolder = filepath.Join(os.Getenv("HOME"), ".cache")
}
}