Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUnimplemented = errors.New("unimplemented") ErrNotStarted = errors.New("command not started") )
View Source
var ( DefaultGracePeriod time.Duration = 30 * time.Second DefaultErrorLog Logger = new(nopLogger) DefaultNewProcessFunc NewProcessFunc = NewOSProcess )
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
func CommandContext ¶
Example ¶
package main import ( "context" "fmt" "time" "github.com/izumin5210/execx" ) func main() { ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) defer cancel() cmd := execx.CommandContext(ctx, "sh", "-c", "sleep 5; echo done") out, err := cmd.Output() st := err.(*execx.ExitStatus) fmt.Println(out, err, st.Signaled, st.Killed) }
Output: [] signal: terminated true false
func (*Cmd) CombinedOutput ¶
type Config ¶
type Config struct { GracePeriod time.Duration NewProcessFunc NewProcessFunc ErrorLog Logger }
type ExitStatus ¶
ExitStatus stores exit information of the command
func (*ExitStatus) Error ¶
func (es *ExitStatus) Error() string
type FakeProcess ¶
type FakeProcess struct { RunFunc func(ctx context.Context, cmd *exec.Cmd) error // contains filtered or unexported fields }
func (*FakeProcess) Kill ¶
func (p *FakeProcess) Kill() error
func (*FakeProcess) Signal ¶
func (p *FakeProcess) Signal() os.Signal
func (*FakeProcess) Start ¶
func (p *FakeProcess) Start() error
func (*FakeProcess) Terminate ¶
func (p *FakeProcess) Terminate() error
func (*FakeProcess) Wait ¶
func (p *FakeProcess) Wait() <-chan *ExitStatus
type NewProcessFunc ¶
func NewFakeNewProcessFunc ¶
type Option ¶
type Option func(*Config)
func WithErrorLog ¶
func WithGracePeriod ¶
func WithNewProcessFunc ¶
func WithNewProcessFunc(f NewProcessFunc) Option
Click to show internal directories.
Click to hide internal directories.