GetHomeDir returns the user's home directory. Returns an empty string if the home directory cannot be determined.
()
| 123 | // |
| 124 | // Returns an empty string if the home directory cannot be determined. |
| 125 | func GetHomeDir() string { |
| 126 | homeDir, err := os.UserHomeDir() |
| 127 | if err != nil { |
| 128 | return "" |
| 129 | } |
| 130 | return filepath.Clean(homeDir) |
| 131 | } |
no outgoing calls