mirror of
https://github.com/chenasraf/stimvisor.git
synced 2026-05-18 01:39:07 +00:00
36 lines
764 B
Go
36 lines
764 B
Go
package common
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
)
|
|
|
|
func GetConfigDir() string {
|
|
if os.Getenv("XDG_CONFIG_HOME") != "" {
|
|
return filepath.Join(os.Getenv("XDG_CONFIG_HOME"), "stimvisor")
|
|
}
|
|
if runtime.GOOS == "windows" {
|
|
return filepath.Join(os.Getenv("APPDATA"), "stimvisor")
|
|
}
|
|
home, err := os.UserHomeDir()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return filepath.Join(home, ".config", "stimvisor")
|
|
}
|
|
|
|
func GetCacheDir() string {
|
|
if os.Getenv("XDG_CACHE_HOME") != "" {
|
|
return filepath.Join(os.Getenv("XDG_CACHE_HOME"), "stimvisor")
|
|
}
|
|
if runtime.GOOS == "windows" {
|
|
return filepath.Join(os.Getenv("LOCALAPPDATA"), "stimvisor")
|
|
}
|
|
home, err := os.UserHomeDir()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return filepath.Join(home, ".cache", "stimvisor")
|
|
}
|