Use HOME for Barnard config path

This commit is contained in:
Storm Dragon
2026-06-29 20:34:14 -04:00
parent 342f934029
commit e1ae5abab9
2 changed files with 16 additions and 5 deletions
+3 -5
View File
@@ -7,7 +7,6 @@ import (
"github.com/pelletier/go-toml/v2"
"io/ioutil"
"os"
"os/user"
"strconv"
"strings"
)
@@ -398,15 +397,14 @@ func fileExists(path string) bool {
func resolvePath(path string) string {
if strings.HasPrefix(path, "~/") || strings.Contains(path, "$HOME") {
usr, err := user.Current()
homeDir, err := os.UserHomeDir()
if err != nil {
panic(err)
}
var hd = usr.HomeDir
if strings.Contains(path, "$HOME") {
path = strings.Replace(path, "$HOME", hd, 1)
path = strings.Replace(path, "$HOME", homeDir, 1)
} else {
path = strings.Replace(path, "~", hd, 1)
path = strings.Replace(path, "~", homeDir, 1)
}
}
return path