From c4c707907dc96dad491ab3603e24a47c2613b057 Mon Sep 17 00:00:00 2001 From: vitalii Date: Sun, 15 Dec 2019 01:28:41 +0200 Subject: [PATCH] fix method of getting user's home path --- cmd/gowebdav/main.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/cmd/gowebdav/main.go b/cmd/gowebdav/main.go index e0f6692..8d8f45c 100644 --- a/cmd/gowebdav/main.go +++ b/cmd/gowebdav/main.go @@ -9,6 +9,7 @@ import ( "os" "os/user" "path/filepath" + "runtime" "strings" ) @@ -66,10 +67,21 @@ func fail(err interface{}) { } func getHome() string { - if u, e := user.Current(); e != nil { + u, e := user.Current() + if e != nil { + return os.Getenv("HOME") + } + + if u != nil { return u.HomeDir } - return os.Getenv("HOME") + + switch runtime.GOOS { + case "windows": + return "" + default: + return "~/" + } } func getCmd(method string) func(c *d.Client, p0, p1 string) error {