mirror of
https://github.com/thegeeklab/wp-plugin-go.git
synced 2024-11-22 00:20:38 +00:00
16 lines
336 B
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
|
|
}
|