go rewrite
This commit is contained in:
parent
3a9d220140
commit
d4290ff553
21 changed files with 437 additions and 552 deletions
21
internal/exec/exec.go
Normal file
21
internal/exec/exec.go
Normal file
|
@ -0,0 +1,21 @@
|
|||
package exec
|
||||
|
||||
import (
|
||||
"os/exec"
|
||||
|
||||
"gomon/internal/logger"
|
||||
)
|
||||
|
||||
// execute a command with args and returns its output
|
||||
// this will be used primarily for executing external commands if configured
|
||||
// or executing bash commands verbatim
|
||||
func ExecCommand(name string, arg ...string) error {
|
||||
cmd := exec.Command(name, arg...)
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
logger.Error("Failed to execute command")
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
Reference in a new issue