minitor-go/util.go

29 lines
526 B
Go
Raw Permalink Normal View History

2019-09-21 22:03:26 +00:00
package main
import (
"os/exec"
"strings"
)
2019-09-21 22:03:26 +00:00
2019-10-02 23:09:11 +00:00
// ShellCommand takes a string and executes it as a command using `sh`
func ShellCommand(command string) *exec.Cmd {
shellCommand := []string{"sh", "-c", strings.TrimSpace(command)}
2021-05-11 03:12:18 +00:00
return exec.Command(shellCommand[0], shellCommand[1:]...)
}
// EqualSliceString checks if two string slices are equivalent
func EqualSliceString(a, b []string) bool {
if len(a) != len(b) {
return false
}
2021-05-11 04:00:58 +00:00
for i, val := range a {
if val != b[i] {
return false
}
}
2021-05-11 04:00:58 +00:00
return true
}