usershell

package
v2.32.3 Latest Latest
Warning

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

Go to latest
Published: May 18, 2026 License: AGPL-3.0 Imports: 4 Imported by: 1 module, 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

This section is empty.

Functions

func Get

func Get(username string) (string, error)

Get returns the /etc/passwd entry for the username provided. Deprecated: use SystemEnvInfo.UserShell instead.

func HomeDir added in v2.21.0

func HomeDir() (string, error)

HomeDir returns the home directory of the current user, giving priority to the $HOME environment variable. Deprecated: use EnvInfoer.HomeDir() instead.

Types

type EnvInfoer added in v2.21.0

type EnvInfoer interface {
	// User returns the current user.
	User() (*user.User, error)
	// Environ returns the environment variables of the current process.
	Environ() []string
	// HomeDir returns the home directory of the current user.
	HomeDir() (string, error)
	// Shell returns the shell of the given user.
	Shell(username string) (string, error)
	// ModifyCommand modifies the command and arguments before execution based on
	// the environment. This is useful for executing a command inside a container.
	// In the default case, the command and arguments are returned unchanged.
	ModifyCommand(name string, args ...string) (string, []string)
}

EnvInfoer encapsulates external information about the environment.

type SystemEnvInfo added in v2.21.0

type SystemEnvInfo struct{}

SystemEnvInfo encapsulates the information about the environment just using the default Go implementations.

func (SystemEnvInfo) Environ added in v2.21.0

func (SystemEnvInfo) Environ() []string

func (SystemEnvInfo) HomeDir added in v2.21.0

func (SystemEnvInfo) HomeDir() (string, error)

func (SystemEnvInfo) ModifyCommand added in v2.21.0

func (SystemEnvInfo) ModifyCommand(name string, args ...string) (string, []string)

func (SystemEnvInfo) Shell added in v2.21.0

func (SystemEnvInfo) Shell(username string) (string, error)

func (SystemEnvInfo) User added in v2.21.0

func (SystemEnvInfo) User() (*user.User, error)

Jump to

Keyboard shortcuts

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