pkg/user: Support 32bit darwin in user package.

master
Harshavardhana 9 years ago
parent e79a73a3f5
commit 42fcb27308
  1. 18
      pkg/user/user.go

@ -39,14 +39,16 @@ func Current() (*user.User, error) {
} }
return &user.User{Uid: "0", Gid: "0", Username: "root", Name: "root", HomeDir: wd}, nil return &user.User{Uid: "0", Gid: "0", Username: "root", Name: "root", HomeDir: wd}, nil
} }
if runtime.GOARCH == "386" && runtime.GOOS == "linux" { if runtime.GOARCH == "386" {
return &user.User{ if runtime.GOOS == "linux" || runtime.GOOS == "darwin" {
Uid: strconv.Itoa(os.Getuid()), return &user.User{
Gid: strconv.Itoa(os.Getgid()), Uid: strconv.Itoa(os.Getuid()),
Username: os.Getenv("USER"), Gid: strconv.Itoa(os.Getgid()),
Name: os.Getenv("USER"), Username: os.Getenv("USER"),
HomeDir: os.Getenv("HOME"), Name: os.Getenv("USER"),
}, nil HomeDir: os.Getenv("HOME"),
}, nil
}
} }
user, e := user.Current() user, e := user.Current()
if e != nil { if e != nil {

Loading…
Cancel
Save