GetHomeDir returns the home directory of the current user with the help of environment variables depending on the target operating system. Returned path should be used with "path/filepath" to form new paths. On non-Windows platforms, it falls back to nss lookups, if the home directory cannot be obt
()
| 546 | // |
| 547 | // Adapted from https://github.com/moby/moby/blob/master/pkg/homedir/homedir.go |
| 548 | func GetHomeDir() string { |
| 549 | home, _ := os.UserHomeDir() |
| 550 | if home == "" && runtime.GOOS != "windows" { |
| 551 | if u, err := user.Current(); err == nil { |
| 552 | return u.HomeDir |
| 553 | } |
| 554 | } |
| 555 | return home |
| 556 | } |
| 557 | |
| 558 | // CurlDiagnosticSuffix is the marker used by ExtractCurlBody to separate |
| 559 | // the response body from diagnostic information appended by curl's -w option. |
no outgoing calls