UserHomeDir gets the user's home directory
()
| 46 | |
| 47 | // UserHomeDir gets the user's home directory |
| 48 | func UserHomeDir() string { |
| 49 | if runtime.GOOS == "windows" { |
| 50 | home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") |
| 51 | if home == "" { |
| 52 | home = os.Getenv("USERPROFILE") |
| 53 | } |
| 54 | return home |
| 55 | } |
| 56 | return os.Getenv("HOME") |
| 57 | } |
| 58 | |
| 59 | // DieIfError kills the program if err is not nil. |
| 60 | // func DieIfError(err error, message string) { |