2011-05-20 02:18:15 +02:00
|
|
|
// Copyright 2011 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// Package user allows user account lookups by name or id.
|
|
|
|
package user
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
2012-02-09 09:19:58 +01:00
|
|
|
var implemented = true // set to false by lookup_stubs.go's init
|
2011-09-16 17:47:21 +02:00
|
|
|
|
2011-05-20 02:18:15 +02:00
|
|
|
// User represents a user account.
|
2012-02-09 09:19:58 +01:00
|
|
|
//
|
|
|
|
// On posix systems Uid and Gid contain a decimal number
|
|
|
|
// representing uid and gid. On windows Uid and Gid
|
|
|
|
// contain security identifier (SID) in a string format.
|
2013-11-06 20:49:01 +01:00
|
|
|
// On Plan 9, Uid, Gid, Username, and Name will be the
|
|
|
|
// contents of /dev/user.
|
2011-05-20 02:18:15 +02:00
|
|
|
type User struct {
|
2012-02-09 09:19:58 +01:00
|
|
|
Uid string // user id
|
|
|
|
Gid string // primary group id
|
2011-05-20 02:18:15 +02:00
|
|
|
Username string
|
|
|
|
Name string
|
|
|
|
HomeDir string
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnknownUserIdError is returned by LookupId when
|
|
|
|
// a user cannot be found.
|
|
|
|
type UnknownUserIdError int
|
|
|
|
|
2011-12-03 03:17:34 +01:00
|
|
|
func (e UnknownUserIdError) Error() string {
|
2011-05-20 02:18:15 +02:00
|
|
|
return "user: unknown userid " + strconv.Itoa(int(e))
|
|
|
|
}
|
|
|
|
|
|
|
|
// UnknownUserError is returned by Lookup when
|
|
|
|
// a user cannot be found.
|
|
|
|
type UnknownUserError string
|
|
|
|
|
2011-12-03 03:17:34 +01:00
|
|
|
func (e UnknownUserError) Error() string {
|
2011-05-20 02:18:15 +02:00
|
|
|
return "user: unknown user " + string(e)
|
|
|
|
}
|