go rewrite

This commit is contained in:
raf 2024-01-11 22:51:07 +03:00
commit d4290ff553
No known key found for this signature in database
GPG key ID: 02D1DD3FA08B6B29
21 changed files with 437 additions and 552 deletions

21
internal/exec/exec.go Normal file
View 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
}