32
// Current returns the current user.
33
func Current() (*User, error) {
34
return lookup(syscall.Getuid(), "", false)
37
// Lookup looks up a user by username. If the user cannot be found,
38
// the returned error is of type UnknownUserError.
39
func Lookup(username string) (*User, error) {
40
return lookup(-1, username, true)
43
// LookupId looks up a user by userid. If the user cannot be found,
44
// the returned error is of type UnknownUserIdError.
45
func LookupId(uid string) (*User, error) {
32
func current() (*User, error) {
33
return lookupUnix(syscall.Getuid(), "", false)
36
func lookup(username string) (*User, error) {
37
return lookupUnix(-1, username, true)
40
func lookupId(uid string) (*User, error) {
46
41
i, e := strconv.Atoi(uid)
50
return lookup(i, "", false)
45
return lookupUnix(i, "", false)
53
func lookup(uid int, username string, lookupByName bool) (*User, error) {
48
func lookupUnix(uid int, username string, lookupByName bool) (*User, error) {
54
49
var pwd C.struct_passwd
55
50
var result *C.struct_passwd