diff --git a/goutil.go b/goutil.go index a0989e5..2530045 100644 --- a/goutil.go +++ b/goutil.go @@ -8,6 +8,7 @@ import ( "io/ioutil" "os" "os/exec" + "os/user" "path/filepath" "runtime" "strings" @@ -100,6 +101,15 @@ func DirsWithPrefix(path string, prefix string) ([]string, error) { return dirs, nil } +func HomeDir() (string, error) { + d := "" + currentUser, err := user.Current() + if err == nil { + d = currentUser.HomeDir + } + return d, err +} + func AskFor(question string) (string, error) { fmt.Print(question + ": ") reader := bufio.NewReader(os.Stdin)