diff --git a/paths.go b/paths.go index a00d227..12622d6 100644 --- a/paths.go +++ b/paths.go @@ -2,13 +2,24 @@ package main import ( + "os" "os/user" + "runtime" "strings" ) func presentPath(path string) string { - usr, _ := user.Current() - homeDir := usr.HomeDir + homeDir := "" + usr, err := user.Current() + if err == nil { + homeDir = usr.HomeDir + } else { + if runtime.GOOS == "windows" { + homeDir = os.Getenv("HOMEPATH") + } else { + homeDir = os.Getenv("HOME") + } + } if !strings.HasPrefix(path, homeDir) { return path }