Skip to content

Commit

Permalink
remove one liner func
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhamlett committed Sep 21, 2021
1 parent 40feaaf commit 92ac7f7
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions pkg/pwd/pwd_cgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,19 @@ type Passwd struct {
Shell string // shell program
}

func cpasswd2go(cpw *C.struct_passwd) *Passwd {
return &Passwd{
Name: C.GoString(cpw.pw_name),
Passwd: C.GoString(cpw.pw_passwd),
UID: uint32(cpw.pw_uid),
GID: uint32(cpw.pw_uid),
Gecos: C.GoString(cpw.pw_gecos),
Dir: C.GoString(cpw.pw_dir),
Shell: C.GoString(cpw.pw_shell),
}
}

// Getpwuid searches the user database for an entry with a matching uid.
func Getpwuid(uid uint32) *Passwd {
cpw := C.getpwuid_aux(C.uint(uid))
if cpw != nil {
return cpasswd2go(cpw)
return &Passwd{
Name: C.GoString(cpw.pw_name),
Passwd: C.GoString(cpw.pw_passwd),
UID: uint32(cpw.pw_uid),
GID: uint32(cpw.pw_uid),
Gecos: C.GoString(cpw.pw_gecos),
Dir: C.GoString(cpw.pw_dir),
Shell: C.GoString(cpw.pw_shell),
}
}

return nil
Expand Down

0 comments on commit 92ac7f7

Please sign in to comment.