Skip to content

Commit

Permalink
fix method of getting user's home path
Browse files Browse the repository at this point in the history
  • Loading branch information
MrVine committed Dec 14, 2019
1 parent 9f625b1 commit c4c7079
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cmd/gowebdav/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"os"
"os/user"
"path/filepath"
"runtime"
"strings"
)

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit c4c7079

Please sign in to comment.