blob: 8089b6e56045d3f9802c13f1c15f53468f2c9c5e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
package config
import (
"fmt"
"os"
)
var userHomeDir = os.UserHomeDir
// HomeDir returns the user's home directory.
//
// It falls back to "." when the home directory cannot be resolved so callers
// can still build a safe relative path instead of joining against an empty
// string.
func HomeDir() (string, error) {
homeDir, err := userHomeDir()
if err != nil {
return ".", fmt.Errorf("resolve home directory: %w", err)
}
return homeDir, nil
}
|