package main import ( "fmt" "os" gohealthchecks "git.faercol.me/faercol/go-healthchecks" "github.com/spf13/cobra" ) var failureCmd = &cobra.Command{ Use: "failure", Short: "Signal the check has failed", Long: ``, Run: func(cmd *cobra.Command, args []string) { check := parseCheckFlags() clt := gohealthchecks.NewPingClient(pingHost) err := clt.ReportFailure(cmd.Context(), check) if err != nil { failf("Failed to notify failure: %s\n", err) } else { fmt.Println("Notified check failure") os.Exit(0) } }, } func init() { rootCmd.AddCommand(failureCmd) }