From 47971d39ec3eb017cd77b5d33ff7eafa4637d4d8 Mon Sep 17 00:00:00 2001 From: Jay Gabriels Date: Sun, 22 Apr 2018 21:07:00 -0700 Subject: [PATCH] use homedir lib --- main.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 4067c63..59c667b 100644 --- a/main.go +++ b/main.go @@ -3,10 +3,10 @@ package main import ( "fmt" "log" - "os" "github.com/gabrie30/ghorg/cmd" "github.com/joho/godotenv" + homedir "github.com/mitchellh/go-homedir" ) func main() { @@ -15,8 +15,13 @@ func main() { } func init() { - home := os.Getenv("HOME") - err := godotenv.Load(home + "/.ghorg") + home, err := homedir.Dir() + + if err != nil { + log.Fatal("Error trying to find users home directory") + } + + err = godotenv.Load(home + "/.ghorg") if err != nil { log.Fatal("Error loading .ghorg file, create a .env from the sample and run Make install") }