Documentation ¶
Index ¶
- func DarwinSudo(cmd string, opt ...SudoOption) error
- func DarwinSudoRaw(ctx context.Context, verbose string, cwd string, env map[string]string, ...) error
- func IAmAdmin() bool
- func IsFileUnreadAndUnWritable(f string) bool
- func LinuxPKExecSudo(cmd string, opt ...SudoOption) error
- func Sudo(cmd string, opt ...SudoOption) error
- func WindowsSudo(cmd string, opts ...SudoOption) error
- type SudoConfig
- type SudoOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DarwinSudo ¶
func DarwinSudo(cmd string, opt ...SudoOption) error
func DarwinSudoRaw ¶
func LinuxPKExecSudo ¶
func LinuxPKExecSudo(cmd string, opt ...SudoOption) error
func Sudo ¶
func Sudo(cmd string, opt ...SudoOption) error
func WindowsSudo ¶
func WindowsSudo(cmd string, opts ...SudoOption) error
Types ¶
type SudoConfig ¶
type SudoConfig struct { // 提示语,一般用于告诉用户这个 Sudo 是用来干嘛的 Verbose string // CWD: 命令执行的目录是啥 Workdir string // Env Environments map[string]string // 用于控制生命周期 Ctx context.Context Stdout, Stderr io.Writer ExitCodeHandler func(int) }
func NewDefaultSudoConfig ¶
func NewDefaultSudoConfig() *SudoConfig
type SudoOption ¶
type SudoOption func(config *SudoConfig)
func WithContext ¶
func WithContext(ctx context.Context) SudoOption
func WithEnv ¶
func WithEnv(k, v string) SudoOption
func WithExitCodeHandler ¶
func WithExitCodeHandler(i func(int)) SudoOption
func WithStderr ¶
func WithStderr(w io.Writer) SudoOption
func WithStdout ¶
func WithStdout(w io.Writer) SudoOption
func WithVerbose ¶
func WithVerbose(i string) SudoOption
func WithWorkdir ¶
func WithWorkdir(i string) SudoOption
Click to show internal directories.
Click to hide internal directories.