github.com/elopio/cli@v6.21.2-0.20160902224010-ea909d1fdb2f+incompatible/utils/config/home_dir_windows.go (about) 1 // +build windows 2 3 package config 4 5 import ( 6 "os" 7 "path/filepath" 8 ) 9 10 // See: http://stackoverflow.com/questions/7922270/obtain-users-home-directory 11 // we can't cross compile using cgo and use user.Current() 12 func homeDirectory() string { 13 var homeDir string 14 switch { 15 case os.Getenv("CF_HOME") != "": 16 homeDir = os.Getenv("CF_HOME") 17 case os.Getenv("HOMEDRIVE")+os.Getenv("HOMEPATH") != "": 18 homeDir = os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") 19 default: 20 homeDir = os.Getenv("USERPROFILE") 21 } 22 return homeDir 23 } 24 25 func defaultFilePath() string { 26 return filepath.Join(homeDirectory(), ".cf", "config.json") 27 }