use homedir lib

This commit is contained in:
Jay Gabriels
2018-04-22 21:07:00 -07:00
parent 09a2ffc15a
commit 47971d39ec

11
main.go
View File

@@ -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")
}