Support utils.HomeDir/0

Support function for returning the home directory of the current user.
This commit is contained in:
William Carroll 2020-02-11 17:01:28 +00:00
parent 825d6f2c65
commit 3ae3b6f039

View file

@ -7,8 +7,18 @@ import (
"log"
"net/http"
"net/http/httputil"
"os/user"
)
// Return the absolute path to the current uesr's home directory.
func HomeDir() string {
user, err := user.Current()
if err != nil {
log.Fatal(err)
}
return user.HomeDir
}
// Call log.Fatal with `err` when it's not nil.
func FailOn(err error) {
if err != nil {