Commit 0ab8a175 authored by Felix Lange's avatar Felix Lange

Merge pull request #2110 from LefterisJP/determining_home_for_ubuntu_core

common: Fix HomeDir detection
parents 32226f1b e2fdd335
...@@ -63,13 +63,14 @@ func AbsolutePath(Datadir string, filename string) string { ...@@ -63,13 +63,14 @@ func AbsolutePath(Datadir string, filename string) string {
return filepath.Join(Datadir, filename) 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 { if usr, err := user.Current(); err == nil {
home = usr.HomeDir return usr.HomeDir
} else {
home = os.Getenv("HOME")
} }
return return ""
} }
func DefaultDataDir() string { func DefaultDataDir() string {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment