i have the following code
package main
import (
"os/exec"
"fmt"
"os"
)
func main() {
cmd := exec.Command("systemctl", "check", "sshd")
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Println("Cannot find process")
os.Exit(1)
}
fmt.Printf("Status is: %s", string(out))
fmt.Println("Starting Role")
If the service is down, program will exit, althrough i would like to get its status ( 'down' , 'inactive', etc)
If the service is up, program will not exit and will print ' active ' output
Any hints, please ?