command

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandExists

func CommandExists(command string) bool

CommandExists 检查命令是否存在

func ExecBackground

func ExecBackground(command string) (*exec.Cmd, error)

ExecBackground 后台执行命令(不等待完成)

func ExecCombined

func ExecCombined(command string) (string, error)

ExecCombined 执行命令并返回合并的输出

func ExecResultBytes

func ExecResultBytes(command string) ([]byte, error)

ExecResultBytes 执行命令并返回字节数组

func ExecResultStr

func ExecResultStr(command string) (string, error)

ExecResultStr 执行命令并返回输出字符串

func ExecStream

func ExecStream(command string, onOutput func(line string)) error

ExecStream 流式输出命令执行结果

func ExecStreamWithContext

func ExecStreamWithContext(ctx context.Context, command string, onOutput func(line string)) error

ExecStreamWithContext 带上下文的流式命令执行

func ExecSuccess

func ExecSuccess(command string) bool

ExecSuccess 执行命令返回是否成功

func ExecWithDir

func ExecWithDir(command string, dir string) (string, error)

ExecWithDir 在指定目录执行命令

func ExecWithEnv

func ExecWithEnv(command string, env map[string]string) (string, error)

ExecWithEnv 带环境变量执行命令

func ExecWithTimeout

func ExecWithTimeout(command string, timeout time.Duration) (string, error)

ExecWithTimeout 带超时的命令执行

func KillProcess

func KillProcess(pid int) error

KillProcess 终止进程

func KillProcessGroup

func KillProcessGroup(pgid int) error

KillProcessGroup 终止进程组

func Which

func Which(command string) (string, error)

Which 查找命令路径

Types

This section is empty.

Jump to

Keyboard shortcuts

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