diff options
Diffstat (limited to 'devdocs/go/os%2Fuser%2Findex.html')
| -rw-r--r-- | devdocs/go/os%2Fuser%2Findex.html | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/devdocs/go/os%2Fuser%2Findex.html b/devdocs/go/os%2Fuser%2Findex.html new file mode 100644 index 00000000..a69f79e8 --- /dev/null +++ b/devdocs/go/os%2Fuser%2Findex.html @@ -0,0 +1,79 @@ +<h1> Package user </h1> <ul id="short-nav"> +<li><code>import "os/user"</code></li> +<li><a href="#pkg-overview" class="overviewLink">Overview</a></li> +<li><a href="#pkg-index" class="indexLink">Index</a></li> +</ul> <h2 id="pkg-overview">Overview </h2> <p>Package user allows user account lookups by name or id. </p> +<p>For most Unix systems, this package has two internal implementations of resolving user and group ids to names, and listing supplementary group IDs. One is written in pure Go and parses /etc/passwd and /etc/group. The other is cgo-based and relies on the standard C library (libc) routines such as getpwuid_r, getgrnam_r, and getgrouplist. </p> +<p>When cgo is available, and the required routines are implemented in libc for a particular platform, cgo-based (libc-backed) code is used. This can be overridden by using osusergo build tag, which enforces the pure Go implementation. </p> <h2 id="pkg-index">Index </h2> <ul id="manual-nav"> +<li><a href="#Group">type Group</a></li> +<li> <a href="#LookupGroup">func LookupGroup(name string) (*Group, error)</a> +</li> +<li> <a href="#LookupGroupId">func LookupGroupId(gid string) (*Group, error)</a> +</li> +<li><a href="#UnknownGroupError">type UnknownGroupError</a></li> +<li> <a href="#UnknownGroupError.Error">func (e UnknownGroupError) Error() string</a> +</li> +<li><a href="#UnknownGroupIdError">type UnknownGroupIdError</a></li> +<li> <a href="#UnknownGroupIdError.Error">func (e UnknownGroupIdError) Error() string</a> +</li> +<li><a href="#UnknownUserError">type UnknownUserError</a></li> +<li> <a href="#UnknownUserError.Error">func (e UnknownUserError) Error() string</a> +</li> +<li><a href="#UnknownUserIdError">type UnknownUserIdError</a></li> +<li> <a href="#UnknownUserIdError.Error">func (e UnknownUserIdError) Error() string</a> +</li> +<li><a href="#User">type User</a></li> +<li> <a href="#Current">func Current() (*User, error)</a> +</li> +<li> <a href="#Lookup">func Lookup(username string) (*User, error)</a> +</li> +<li> <a href="#LookupId">func LookupId(uid string) (*User, error)</a> +</li> +<li> <a href="#User.GroupIds">func (u *User) GroupIds() ([]string, error)</a> +</li> +</ul> <h3>Package files</h3> <p> <span>cgo_listgroups_unix.go</span> <span>cgo_lookup_cgo.go</span> <span>cgo_lookup_unix.go</span> <span>getgrouplist_unix.go</span> <span>lookup.go</span> <span>user.go</span> </p> <h2 id="Group">type <span>Group</span> <span title="Added in Go 1.7">1.7</span> </h2> <p>Group represents a grouping of users. </p> +<p>On POSIX systems Gid contains a decimal number representing the group ID. </p> +<pre data-language="go">type Group struct { + Gid string // group ID + Name string // group name +} +</pre> <h3 id="LookupGroup">func <span>LookupGroup</span> <span title="Added in Go 1.7">1.7</span> </h3> <pre data-language="go">func LookupGroup(name string) (*Group, error)</pre> <p>LookupGroup looks up a group by name. If the group cannot be found, the returned error is of type UnknownGroupError. </p> +<h3 id="LookupGroupId">func <span>LookupGroupId</span> <span title="Added in Go 1.7">1.7</span> </h3> <pre data-language="go">func LookupGroupId(gid string) (*Group, error)</pre> <p>LookupGroupId looks up a group by groupid. If the group cannot be found, the returned error is of type UnknownGroupIdError. </p> +<h2 id="UnknownGroupError">type <span>UnknownGroupError</span> <span title="Added in Go 1.7">1.7</span> </h2> <p>UnknownGroupError is returned by LookupGroup when a group cannot be found. </p> +<pre data-language="go">type UnknownGroupError string</pre> <h3 id="UnknownGroupError.Error">func (UnknownGroupError) <span>Error</span> <span title="Added in Go 1.7">1.7</span> </h3> <pre data-language="go">func (e UnknownGroupError) Error() string</pre> <h2 id="UnknownGroupIdError">type <span>UnknownGroupIdError</span> <span title="Added in Go 1.7">1.7</span> </h2> <p>UnknownGroupIdError is returned by LookupGroupId when a group cannot be found. </p> +<pre data-language="go">type UnknownGroupIdError string</pre> <h3 id="UnknownGroupIdError.Error">func (UnknownGroupIdError) <span>Error</span> <span title="Added in Go 1.7">1.7</span> </h3> <pre data-language="go">func (e UnknownGroupIdError) Error() string</pre> <h2 id="UnknownUserError">type <span>UnknownUserError</span> </h2> <p>UnknownUserError is returned by Lookup when a user cannot be found. </p> +<pre data-language="go">type UnknownUserError string</pre> <h3 id="UnknownUserError.Error">func (UnknownUserError) <span>Error</span> </h3> <pre data-language="go">func (e UnknownUserError) Error() string</pre> <h2 id="UnknownUserIdError">type <span>UnknownUserIdError</span> </h2> <p>UnknownUserIdError is returned by LookupId when a user cannot be found. </p> +<pre data-language="go">type UnknownUserIdError int</pre> <h3 id="UnknownUserIdError.Error">func (UnknownUserIdError) <span>Error</span> </h3> <pre data-language="go">func (e UnknownUserIdError) Error() string</pre> <h2 id="User">type <span>User</span> </h2> <p>User represents a user account. </p> +<pre data-language="go">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 +} +</pre> <h3 id="Current">func <span>Current</span> </h3> <pre data-language="go">func Current() (*User, error)</pre> <p>Current returns the current user. </p> +<p>The first call will cache the current user information. Subsequent calls will return the cached value and will not reflect changes to the current user. </p> +<h3 id="Lookup">func <span>Lookup</span> </h3> <pre data-language="go">func Lookup(username string) (*User, error)</pre> <p>Lookup looks up a user by username. If the user cannot be found, the returned error is of type UnknownUserError. </p> +<h3 id="LookupId">func <span>LookupId</span> </h3> <pre data-language="go">func LookupId(uid string) (*User, error)</pre> <p>LookupId looks up a user by userid. If the user cannot be found, the returned error is of type UnknownUserIdError. </p> +<h3 id="User.GroupIds">func (*User) <span>GroupIds</span> <span title="Added in Go 1.7">1.7</span> </h3> <pre data-language="go">func (u *User) GroupIds() ([]string, error)</pre> <p>GroupIds returns the list of group IDs that the user is a member of. </p><div class="_attribution"> + <p class="_attribution-p"> + © Google, Inc.<br>Licensed under the Creative Commons Attribution License 3.0.<br> + <a href="http://golang.org/pkg/os/user/" class="_attribution-link">http://golang.org/pkg/os/user/</a> + </p> +</div> |
