github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/util/configv3/home_dir_windows.go (about) 1 // +build windows 2 3 package configv3 4 5 import ( 6 "os" 7 "path/filepath" 8 ) 9 10 // ConfigFilePath returns the location of the config file 11 func ConfigFilePath() string { 12 return filepath.Join(homeDirectory(), ".cf", "config.json") 13 } 14 15 func configDirectory() string { 16 return filepath.Join(homeDirectory(), ".cf") 17 } 18 19 // See: http://stackoverflow.com/questions/7922270/obtain-users-home-directory 20 // we can't cross compile using cgo and use user.Current() 21 func homeDirectory() string { 22 var homeDir string 23 switch { 24 case os.Getenv("CF_HOME") != "": 25 homeDir = os.Getenv("CF_HOME") 26 case os.Getenv("HOMEDRIVE")+os.Getenv("HOMEPATH") != "": 27 homeDir = os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") 28 default: 29 homeDir = os.Getenv("USERPROFILE") 30 } 31 return homeDir 32 }