Thanks to visit codestin.com
Credit goes to pkg.go.dev

usershell

package
v2.21.3 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: AGPL-3.0 Imports: 4 Imported by: 0

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