0
0
mirror of https://github.com/thegeeklab/wp-plugin-go.git synced 2024-11-24 23:20:41 +00:00
wp-plugin-go/util/user.go

16 lines
336 B
Go

package util
import "os/user"
// GetUserHomeDir returns the home directory path for the current user.
// If the current user cannot be determined, it returns the default "/root" path.
func GetUserHomeDir() string {
home := "/root"
if currentUser, err := user.Current(); err == nil {
home = currentUser.HomeDir
}
return home
}