123456789101112131415161718192021222324252627 |
- package executor
- import "os/exec"
- // SyncExecutor executes commands with os/exec
- type SyncExecutor interface {
- RunSync(string, ...string) ([]byte, error)
- }
- // AsyncExecutor starts process and stops it
- type AsyncExecutor interface {
- StartAsync(string, ...string) (*exec.Cmd, error)
- StopAsync(*exec.Cmd) error
- }
- func RunSync(executor SyncExecutor, command string, args ...string) ([]byte, error) {
- return executor.RunSync(command, args...)
- }
- func RunAsync(runner AsyncExecutor, command string, args ...string) (*exec.Cmd, error) {
- return runner.StartAsync(command, args...)
- }
- func StopAsync(stopper AsyncExecutor, prc *exec.Cmd) error {
- return stopper.StopAsync(prc)
- }
|