1package dbus 2 3import ( 4 "os" 5 "sync" 6) 7 8var ( 9 homeDir string 10 homeDirLock sync.Mutex 11) 12 13func getHomeDir() string { 14 homeDirLock.Lock() 15 defer homeDirLock.Unlock() 16 17 if homeDir != "" { 18 return homeDir 19 } 20 21 homeDir = os.Getenv("HOME") 22 if homeDir != "" { 23 return homeDir 24 } 25 26 homeDir = lookupHomeDir() 27 return homeDir 28} 29