Home returns the user's home directory. The HOME environment variable wins so tests and callers can intentionally isolate filesystem behavior on all platforms, including Windows where os.UserHomeDir does not follow HOME.
()
| 14 | // tests and callers can intentionally isolate filesystem behavior on all |
| 15 | // platforms, including Windows where os.UserHomeDir does not follow HOME. |
| 16 | func Home() string { |
| 17 | if dir := os.Getenv("HOME"); dir != "" { |
| 18 | return dir |
| 19 | } |
| 20 | if dir, err := os.UserHomeDir(); err == nil && dir != "" { |
| 21 | return dir |
| 22 | } |
| 23 | return "" |
| 24 | } |
| 25 | |
| 26 | func joinHome(path string) string { |
| 27 | home := Home() |
no outgoing calls
no test coverage detected