Home | History | Annotate | Download | only in user
      1 // Copyright 2011 The Go Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 package user
      6 
      7 // Current returns the current user.
      8 func Current() (*User, error) {
      9 	return current()
     10 }
     11 
     12 // Lookup looks up a user by username. If the user cannot be found, the
     13 // returned error is of type UnknownUserError.
     14 func Lookup(username string) (*User, error) {
     15 	return lookupUser(username)
     16 }
     17 
     18 // LookupId looks up a user by userid. If the user cannot be found, the
     19 // returned error is of type UnknownUserIdError.
     20 func LookupId(uid string) (*User, error) {
     21 	return lookupUserId(uid)
     22 }
     23 
     24 // LookupGroup looks up a group by name. If the group cannot be found, the
     25 // returned error is of type UnknownGroupError.
     26 func LookupGroup(name string) (*Group, error) {
     27 	return lookupGroup(name)
     28 }
     29 
     30 // LookupGroupId looks up a group by groupid. If the group cannot be found, the
     31 // returned error is of type UnknownGroupIdError.
     32 func LookupGroupId(gid string) (*Group, error) {
     33 	return lookupGroupId(gid)
     34 }
     35 
     36 // GroupIds returns the list of group IDs that the user is a member of.
     37 func (u *User) GroupIds() ([]string, error) {
     38 	return listGroups(u)
     39 }
     40