command

package
v0.0.0-...-bcf4c9c Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

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

Command 运行的Shell指令需要参数

func New

func New(name string, args ...string) *Command

New 新建一个Command实例。name为命令路径,args为命令参数

func NewBash

func NewBash(name string, args ...string) *Command

NewBash 创建一个Bash的Command实例

func (*Command) AddArguments

func (cmd *Command) AddArguments(args ...string) *Command

AddArguments 为运行的指令添加参数

func (*Command) AddEnvs

func (cmd *Command) AddEnvs(envs ...string) *Command

AddEnvs 添加环境变量,如: PATH="/bin:/sbin"

func (*Command) Run

func (cmd *Command) Run() (output []byte, err error)

Run 运行命令,并将命令的标准输出,标准错误内容合并到output返回

func (*Command) RunDir

func (cmd *Command) RunDir(dir string) *Command

RunDir 设置运行指令时的工作目录

func (*Command) RunWithPipe

func (cmd *Command) RunWithPipe(stdout, stderr io.Writer) (err error)

RunWithPipe 运行指令,并将命令运行时的标准输出,和标准错误分别输出到stdout, stderr 如果指令运行失败,会返回err

func (*Command) SetTimeout

func (cmd *Command) SetTimeout(timeout time.Duration) *Command

SetTimeout 设置指令运行超时时间

Jump to

Keyboard shortcuts

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