Browse Source

Merge pull request #2110 from LefterisJP/determining_home_for_ubuntu_core

common: Fix HomeDir detection
Felix Lange 9 years ago
parent
commit
0ab8a175d8
1 changed files with 6 additions and 5 deletions
  1. 6 5
      common/path.go

+ 6 - 5
common/path.go

@@ -63,13 +63,14 @@ func AbsolutePath(Datadir string, filename string) string {
 	return filepath.Join(Datadir, filename)
 }
 
-func HomeDir() (home string) {
+func HomeDir() string {
+	if home := os.Getenv("HOME"); home != "" {
+		return home
+	}
 	if usr, err := user.Current(); err == nil {
-		home = usr.HomeDir
-	} else {
-		home = os.Getenv("HOME")
+		return usr.HomeDir
 	}
-	return
+	return ""
 }
 
 func DefaultDataDir() string {