prefer $APPDATA over $HOME in Windows (#9830)

This commit is contained in:
Rui Lopes
2020-08-31 14:35:15 +02:00
committed by GitHub
parent e4f975fae1
commit 281af9a03d
+7 -3
View File
@@ -22,12 +22,16 @@ func ConfigDir() (string, error) {
}
func homeDir() (string, error) {
// Prefer $HOME over user.Current due to glibc bug: golang.org/issue/13470
if home := os.Getenv("HOME"); home != "" {
// Prefer $APPDATA over $HOME in Windows.
// This makes it possible to use packer plugins (as installed by Chocolatey)
// in cmd/ps and msys2.
// See https://github.com/hashicorp/packer/issues/9795
if home := os.Getenv("APPDATA"); home != "" {
return home, nil
}
if home := os.Getenv("APPDATA"); home != "" {
// Prefer $HOME over user.Current due to glibc bug: golang.org/issue/13470
if home := os.Getenv("HOME"); home != "" {
return home, nil
}