package watcher import ( "fmt" "log" "os" "os/exec" "github.com/fsnotify/fsnotify" ) type NotifyIface interface { NewWatcher() (*fsnotify.Watcher, error) } type WatcherIface interface { Monitor(path string) error Listen(binaryPath, scriptPath string, outputErr chan<- error) Close() error } type DeployFunc func(binaryPath, scriptPath string) error func Deploy(binaryPath, scriptPath string) error { err := execute(binaryPath, scriptPath) if err != nil { return fmt.Errorf("execute: %s", err) } log.Println("deploy done") return nil } func execute(binaryPath, scriptPath string) error { cmd := exec.Command(binaryPath, scriptPath) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr if err := cmd.Run(); err != nil { return fmt.Errorf("cmd.Run %s", err) } return nil }