?
Dieses Dokument verwendet PHP-Handbuch für chinesische Websites Freigeben
import "os/user"
Overview
Index
軟件包用戶允許按名稱或 ID 查找用戶帳戶。
type Group
func LookupGroup(name string) (*Group, error)
func LookupGroupId(gid string) (*Group, error)
type UnknownGroupError
func (e UnknownGroupError) Error() string
type UnknownGroupIdError
func (e UnknownGroupIdError) Error() string
type UnknownUserError
func (e UnknownUserError) Error() string
type UnknownUserIdError
func (e UnknownUserIdError) Error() string
type User
func Current() (*User, error)
func Lookup(username string) (*User, error)
func LookupId(uid string) (*User, error)
func (u *User) GroupIds() ([]string, error)
lookup.go lookup_stubs.go lookup_unix.go user.go
組代表一組用戶。
在 POSIX 系統(tǒng)上, Gid 包含一個表示組 ID 的十進制數(shù)字。
type Group struct { Gid string // group ID Name string // group name}
func LookupGroup(name string) (*Group, error)
LookupGroup 按名稱查找組。如果找不到該組,則返回的錯誤類型為 UnknownGroupError 。
func LookupGroupId(gid string) (*Group, error)
LookupGroupId 通過 groupid 查找一個組。如果找不到該組,則返回的錯誤類型為 UnknownGroupIdError 。
當找不到組時,LookGroup 返回 UnknownGroupError 。
type UnknownGroupError string
func (e UnknownGroupError) Error() string
當找不到組時, LookGroupId 會返回 UnknownGroupIdError 。
type UnknownGroupIdError string
func (e UnknownGroupIdError) Error() string
當找不到用戶時,通過查找返回UnknownUserError。
type UnknownUserError string
func (e UnknownUserError) Error() string
UnknownUserIdError 由 LookupId 在找不到用戶時返回。
type UnknownUserIdError int
func (e UnknownUserIdError) Error() string
用戶代表一個用戶帳戶。
type User struct { // Uid is the user ID. // On POSIX systems, this is a decimal number representing the uid. // On Windows, this is a security identifier (SID) in a string format. // On Plan 9, this is the contents of /dev/user. Uid string // Gid is the primary group ID. // On POSIX systems, this is a decimal number representing the gid. // On Windows, this is a SID in a string format. // On Plan 9, this is the contents of /dev/user. Gid string // Username is the login name. Username string // Name is the user's real or display name. // It might be blank. // On POSIX systems, this is the first (or only) entry in the GECOS field // list. // On Windows, this is the user's display name. // On Plan 9, this is the contents of /dev/user. Name string // HomeDir is the path to the user's home directory (if they have one). HomeDir string}
func Current() (*User, error)
當前返回當前用戶。
func Lookup(username string) (*User, error)
查找通過用戶名查找用戶。如果找不到用戶,則返回的錯誤類型為 UnknownUserError 。
func LookupId(uid string) (*User, error)
LookupId 通過用戶名查找用戶。如果找不到用戶,返回的錯誤類型為 UnknownUserIdError 。
func (u *User) GroupIds() ([]string, error)
GroupIds 返回用戶所屬組 ID 的列表。