File tree 2 files changed +10
-19
lines changed
2 files changed +10
-19
lines changed Original file line number Diff line number Diff line change @@ -19,14 +19,6 @@ var profileFolder_ string
19
19
var config_ * sqlkv.SqlKv
20
20
var profileDb_ * sql.DB
21
21
22
- func userHomeDir () string {
23
- u , err := user .Current ()
24
- if err != nil {
25
- panic (err )
26
- }
27
- return u .HomeDir
28
- }
29
-
30
22
func profileOpen () error {
31
23
if profileDb_ != nil {
32
24
return nil
@@ -74,11 +66,17 @@ func profileFolder() string {
74
66
}
75
67
76
68
if homeDir_ == "" {
77
- u , err := user .Current ()
78
- if err != nil {
79
- panic (err )
69
+ // By default, use $HOME as it seems to be different from HomeDir in some
70
+ // systems. In particular it's necessary to pass Homebrew's tests.
71
+ homeDir_ = os .Getenv ("HOME" )
72
+
73
+ if homeDir_ == "" {
74
+ u , err := user .Current ()
75
+ if err != nil {
76
+ panic (err )
77
+ }
78
+ homeDir_ = u .HomeDir
80
79
}
81
- homeDir_ = u .HomeDir
82
80
}
83
81
84
82
output := filepath .Join (homeDir_ , ".config" , APPNAME )
Original file line number Diff line number Diff line change @@ -6,13 +6,6 @@ import (
6
6
"testing"
7
7
)
8
8
9
- func Test_userHomeDir (t * testing.T ) {
10
- homeDir := userHomeDir ()
11
- if len (homeDir ) == 0 {
12
- t .Fail ()
13
- }
14
- }
15
-
16
9
func Test_profileOpenClose (t * testing.T ) {
17
10
if profileDb_ != nil {
18
11
t .Error ("profileDb_ should be nil" )
You can’t perform that action at this time.
0 commit comments