github.com/4ad/go@v0.0.0-20161219182952-69a12818b605/src/os/user/user.go (about)

     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 allows user account lookups by name or id.
     6  package user
     7  
     8  import (
     9  	"strconv"
    10  )
    11  
    12  var (
    13  	userImplemented  = true // set to false by lookup_stubs.go's init
    14  	groupImplemented = true // set to false by lookup_stubs.go's init
    15  )
    16  
    17  // User represents a user account.
    18  //
    19  // On POSIX systems Uid and Gid contain a decimal number
    20  // representing uid and gid. On windows Uid and Gid
    21  // contain security identifier (SID) in a string format.
    22  // On Plan 9, Uid, Gid, Username, and Name will be the
    23  // contents of /dev/user.
    24  type User struct {
    25  	Uid      string // user ID
    26  	Gid      string // primary group ID
    27  	Username string
    28  	Name     string
    29  	HomeDir  string
    30  }
    31  
    32  // Group represents a grouping of users.
    33  //
    34  // On POSIX systems Gid contains a decimal number
    35  // representing the group ID.
    36  type Group struct {
    37  	Gid  string // group ID
    38  	Name string // group name
    39  }
    40  
    41  // UnknownUserIdError is returned by LookupId when
    42  // a user cannot be found.
    43  type UnknownUserIdError int
    44  
    45  func (e UnknownUserIdError) Error() string {
    46  	return "user: unknown userid " + strconv.Itoa(int(e))
    47  }
    48  
    49  // UnknownUserError is returned by Lookup when
    50  // a user cannot be found.
    51  type UnknownUserError string
    52  
    53  func (e UnknownUserError) Error() string {
    54  	return "user: unknown user " + string(e)
    55  }
    56  
    57  // UnknownGroupIdError is returned by LookupGroupId when
    58  // a group cannot be found.
    59  type UnknownGroupIdError string
    60  
    61  func (e UnknownGroupIdError) Error() string {
    62  	return "group: unknown groupid " + string(e)
    63  }
    64  
    65  // UnknownGroupError is returned by LookupGroup when
    66  // a group cannot be found.
    67  type UnknownGroupError string
    68  
    69  func (e UnknownGroupError) Error() string {
    70  	return "group: unknown group " + string(e)
    71  }