xmtop/vendor/github.com/ProtonMail/go-appdir/appdir_xdg.go
2019-01-14 20:19:17 -08:00

40 lines
776 B
Go

// +build !darwin,!windows
package appdir
import (
"os"
"path/filepath"
)
type dirs struct {
name string
}
func (d *dirs) UserConfig() string {
baseDir := filepath.Join(os.Getenv("HOME"), ".config")
if os.Getenv("XDG_CONFIG_HOME") != "" {
baseDir = os.Getenv("XDG_CONFIG_HOME")
}
return filepath.Join(baseDir, d.name)
}
func (d *dirs) UserCache() string {
baseDir := filepath.Join(os.Getenv("HOME"), ".cache")
if os.Getenv("XDG_CACHE_HOME") != "" {
baseDir = os.Getenv("XDG_CACHE_HOME")
}
return filepath.Join(baseDir, d.name)
}
func (d *dirs) UserLogs() string {
baseDir := filepath.Join(os.Getenv("HOME"), ".local", "state")
if os.Getenv("XDG_STATE_HOME") != "" {
baseDir = os.Getenv("XDG_STATE_HOME")
}
return filepath.Join(baseDir, d.name)
}