diff options
Diffstat (limited to 'users.go')
-rw-r--r-- | users.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/users.go b/users.go new file mode 100644 index 0000000..77101f7 --- /dev/null +++ b/users.go @@ -0,0 +1,23 @@ +package main + +import "os/user" + +func lookupGroupNames(u *user.User) ([]string, error) { + groups, err := u.GroupIds() + if err != nil { + return nil, err + } + + var names []string + + for _, v := range groups { + group, err := user.LookupGroupId(v) + if err != nil { + return nil, err + } + + names = append(names, group.Name) + } + + return names, nil +} |