Codebase list golang-github-mitchellh-go-homedir / 32e698a
Shift up the preference of the USERPROFILE variable Mike Brancato 5 years ago
1 changed file(s) with 6 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
140140 return home, nil
141141 }
142142
143 // Prefer standard environment variable USERPROFILE
144 if home := os.Getenv("USERPROFILE"); home != "" {
145 return home, nil
146 }
147
143148 drive := os.Getenv("HOMEDRIVE")
144149 path := os.Getenv("HOMEPATH")
145150 home := drive + path
146151 if drive == "" || path == "" {
147 home = os.Getenv("USERPROFILE")
148 }
149 if home == "" {
150 return "", errors.New("HOMEDRIVE, HOMEPATH, and USERPROFILE are blank")
152 return "", errors.New("HOMEDRIVE, HOMEPATH, or USERPROFILE are blank")
151153 }
152154
153155 return home, nil