kleinCommand/services/getConfigPath.go
2024-05-24 21:23:01 +02:00

26 lines
504 B
Go

package services
import (
"errors"
"os"
"path/filepath"
"runtime"
)
func GetConfigPath() (path string, configPath string, err error) {
homeDir, _ := os.UserHomeDir()
switch runtime.GOOS {
case "windows":
path = filepath.Dir(homeDir + "\\AppData\\Local\\kleinCommand\\")
case "linux":
path = filepath.Dir(homeDir + "/.config/kleinCommand/")
default:
return "", "", errors.New("unsupported platform")
}
configPath = filepath.Join(path, "/config.toml")
return path, configPath, nil
}