From 94eed819276e28ba38bedc5ab0a287d14ab091bb Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Mon, 14 Aug 2023 21:45:46 -0700 Subject: [PATCH] initial commits --- rootdir.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/rootdir.go b/rootdir.go index 520f3e2..9ead788 100644 --- a/rootdir.go +++ b/rootdir.go @@ -32,27 +32,28 @@ const ( // fmt.Printf("The maymoon root-dir is at %q \n", rootDir) func RootDir() (string, error) { - var path string - { - path = os.Getenv(publicRootEnvName) + path := os.Getenv(publicRootEnvName) if "" != path { /////////////////////// RETURN return path, nil } } + var path string { homedir, err := os.UserHomeDir() if nil != err { - return "", fmt.Errorf("problem getting user home-directory: %s", err) +/////////////////////// RETURN + return "", fmt.Errorf("problem getting user home-directory: %w", err) } - path := filepath.Join(homedir, publicRootDirName) - if "" != path { - return path, nil + path = filepath.Join(homedir, publicRootDirName) + if "" == path { +/////////////////////// RETURN + return "", errors.New("empty path") } } - return "", nil + return path, nil }