git连接:https://github.com/natefinch/deputy
deputy是go包,相当于在os系统上的一个轻量的cmd命令
deputy包结构体
- Deputy 结构体里面包含错误类型
- Cancel :当调用cancel方法时,会调用os底层signal,报出os:process already finished
type Deputy struct {
// Cancel, when closed, will cause the command to close.
Cancel <-chan struct{
}
// Errors describes how errors should be handled.
Errors ErrorHandling
// StdoutLog takes a function that will receive lines written to stdout from
// the command (with the newline elided).
StdoutLog func([]byte)
// StdoutLog takes a function that will receive lines written to stderr from
// the command (with the newline elided).
StderrLog func([]byte)
// contains filtered or unexported fields
}
deputy包错误处理
type ErrorHandling int
const (

本文深入解析了Deputy,一个用于在os系统上执行轻量级cmd命令的Go包。详细介绍了Deputy的结构体设计,包括错误处理机制和Runcmd命令的实现方式。通过示例代码展示了如何使用Deputy包进行命令执行,并设置错误处理和日志记录。
最低0.47元/天 解锁文章
1491

被折叠的 条评论
为什么被折叠?



