Source File
homedir.go
Belonging Package
github.com/mitchellh/go-homedir
package homedir
import (
)
var DisableCache bool
var homedirCache string
var cacheLock sync.RWMutex
, = dirUnix()
}
if != nil {
return "",
}
homedirCache =
return , nil
}
= "home"
}
if runtime.GOOS == "darwin" {
:= exec.Command("sh", "-c", `dscl -q . -read /Users/"$(whoami)" NFSHomeDirectory | sed 's/^[^ ]*: //'`)
.Stdout = &
if := .Run(); == nil {
:= strings.TrimSpace(.String())
if != "" {
return , nil
}
}
} else {
:= exec.Command("getent", "passwd", strconv.Itoa(os.Getuid()))
.Stdout = &
if != exec.ErrNotFound {
return "",
}
} else {
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |