MCPcopy Create free account
hub / github.com/ddev/ddev / GetHomeDir

Function GetHomeDir

pkg/util/utils.go:548–556  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

546//
547// Adapted from https://github.com/moby/moby/blob/master/pkg/homedir/homedir.go
548func 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.

Callers 3

CreateTmpDirFunction · 0.92
TestGetHomeDirFunction · 0.92

Calls

no outgoing calls

Tested by 2

TestGetHomeDirFunction · 0.74