mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 22:20:51 +00:00
Added support for HOME environment variable on Windows
This commit is contained in:
@@ -24,6 +24,13 @@ import (
|
|||||||
// HomeDir returns the home directory for the current user
|
// HomeDir returns the home directory for the current user
|
||||||
func HomeDir() string {
|
func HomeDir() string {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
|
|
||||||
|
// First prefer the HOME environmental variable
|
||||||
|
if home := os.Getenv("HOME"); len(home) > 0 {
|
||||||
|
if _, err := os.Stat(home); err == nil {
|
||||||
|
return home
|
||||||
|
}
|
||||||
|
}
|
||||||
if homeDrive, homePath := os.Getenv("HOMEDRIVE"), os.Getenv("HOMEPATH"); len(homeDrive) > 0 && len(homePath) > 0 {
|
if homeDrive, homePath := os.Getenv("HOMEDRIVE"), os.Getenv("HOMEPATH"); len(homeDrive) > 0 && len(homePath) > 0 {
|
||||||
homeDir := homeDrive + homePath
|
homeDir := homeDrive + homePath
|
||||||
if _, err := os.Stat(homeDir); err == nil {
|
if _, err := os.Stat(homeDir); err == nil {
|
||||||
|
Reference in New Issue
Block a user