user/group.go
func Getgroups() []int {
	user := GetUsername()
	list := make([]int, 0)

	// The user could have its own group.
	if g, err := LookupGroup(user); err == nil {
		list = append(list, g.GID)
	}

	groups, err := LookupInGroup(G_MEMBER, user, -1)
	if err != nil {
		if _, ok := err.(NoFoundError); !ok {
			panic(err)
		}
	}

	for _, v := range groups {
		list = append(list, v.GID)
	}
	return list
}
func Getgroups() []int {
	user := GetUsername()
	list := make([]int, 0)

	// The user could have its own group.
	if g, err := LookupGroup(user); err == nil {
		list = append(list, g.GID)
	}

	groups, err := LookupInGroup(G_MEMBER, user, -1)
	if err != nil {
		if _, ok := err.(NoFoundError); !ok {
			panic(err)
		}
	}

	for _, v := range groups {
		list = append(list, v.GID)
	}
	return list
}
// Getgroups returns a list of the numeric ids of groups that the caller
// belongs to.