userutil

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found in the account database")

Lookup miss, matched with errors.Is on every not-found error of this package

Functions

func LoginName

func LoginName() (string, error)

Login name of this user: LOGNAME, USER, LNAME or USERNAME from the environment, else the name of the account the process runs as

Types

type Account

type Account struct {
	Name  string
	UID   int
	GID   int
	Gecos string
	Home  string
	Shell string
}

Account record of the user database

func All

func All() ([]Account, error)

Every account of the local passwd file in file order, then the accounts only the system directory lists

func Lookup

func Lookup(name string) (Account, error)

Account named name: the local passwd file first, then the system directory (NSS on Linux and the BSDs, Directory Services on macOS), then the C library lookup

func LookupID

func LookupID(uid int) (Account, error)

First account with user id uid, searched like Lookup

type Group

type Group struct {
	Name    string
	GID     int
	Members []string
}

Group record of the group database

func LookupGroupID

func LookupGroupID(gid int) (Group, error)

First group with group id gid and its listed members: the local group file first, then the system directory, then the C library lookup without members

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL