executor

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 7 Imported by: 0 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

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor interface {
	// Run 执行命令并返回标准输出内容
	Run(ctx context.Context, cmd string) (string, error)
	// RunWithSudo 提权执行命令
	RunWithSudo(ctx context.Context, cmd string) (string, error)
	// InteractiveWithSudo 开启交互式提权会话 (如 sudo -s)
	InteractiveWithSudo(ctx context.Context, args []string) error
}

Executor 定义命令执行接口

type LocalExecutor

type LocalExecutor struct {
	// contains filtered or unexported fields
}

LocalExecutor 本地执行器

func NewLocalExecutor

func NewLocalExecutor(password string) *LocalExecutor

func (*LocalExecutor) InteractiveWithSudo

func (e *LocalExecutor) InteractiveWithSudo(ctx context.Context, args []string) error

func (*LocalExecutor) Run

func (e *LocalExecutor) Run(ctx context.Context, cmd string) (string, error)

func (*LocalExecutor) RunWithSudo

func (e *LocalExecutor) RunWithSudo(ctx context.Context, cmd string) (string, error)

type SSHExecutor

type SSHExecutor struct {
	// contains filtered or unexported fields
}

SSHExecutor 包装 ssh.Client 以满足 Executor 接口

func NewSSHExecutor

func NewSSHExecutor(client *ssh.Client) *SSHExecutor

func (*SSHExecutor) InteractiveWithSudo

func (e *SSHExecutor) InteractiveWithSudo(ctx context.Context, args []string) error

func (*SSHExecutor) Run

func (e *SSHExecutor) Run(ctx context.Context, cmd string) (string, error)

func (*SSHExecutor) RunWithSudo

func (e *SSHExecutor) RunWithSudo(ctx context.Context, cmd string) (string, error)

type Transfer

type Transfer interface {
	// Copy 复制文件 (为了统一 SCP 和 本地复制)
	Copy(ctx context.Context, src, dst string) error
}

Transfer 定义文件传输接口

Jump to

Keyboard shortcuts

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