File tree 2 files changed +6
-8
lines changed
2 files changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -468,8 +468,10 @@ func UserHomeDir() (string, error) {
468
468
}
469
469
// On some geese the home directory is not always defined.
470
470
switch runtime .GOOS {
471
- case "nacl" , "android" :
471
+ case "nacl" :
472
472
return "/" , nil
473
+ case "android" :
474
+ return "/sdcard" , nil
473
475
case "darwin" :
474
476
if runtime .GOARCH == "arm" || runtime .GOARCH == "arm64" {
475
477
return "/" , nil
Original file line number Diff line number Diff line change @@ -26,12 +26,14 @@ func current() (*User, error) {
26
26
if err == nil {
27
27
return u , nil
28
28
}
29
+
30
+ homeDir , _ := os .UserHomeDir ()
29
31
u = & User {
30
32
Uid : uid ,
31
33
Gid : currentGID (),
32
34
Username : os .Getenv ("USER" ),
33
35
Name : "" , // ignored
34
- HomeDir : os . Getenv ( "HOME" ) ,
36
+ HomeDir : homeDir ,
35
37
}
36
38
// On NaCL and Android, return a dummy user instead of failing.
37
39
switch runtime .GOOS {
@@ -42,19 +44,13 @@ func current() (*User, error) {
42
44
if u .Username == "" {
43
45
u .Username = "nacl"
44
46
}
45
- if u .HomeDir == "" {
46
- u .HomeDir = "/"
47
- }
48
47
case "android" :
49
48
if u .Uid == "" {
50
49
u .Uid = "1"
51
50
}
52
51
if u .Username == "" {
53
52
u .Username = "android"
54
53
}
55
- if u .HomeDir == "" {
56
- u .HomeDir = "/sdcard"
57
- }
58
54
}
59
55
// cgo isn't available, but if we found the minimum information
60
56
// without it, use it:
You can’t perform that action at this time.
0 commit comments