From a17e31703a6e1bd0f4309bab9979229b5416fa4d Mon Sep 17 00:00:00 2001 From: Mario Trangoni Date: Fri, 23 Dec 2022 12:07:12 +0100 Subject: [PATCH] errcheck: check c.AddFunc return error. See, cmd/mtr-exporter/main.go:53:11: Error return value of `c.AddFunc` is not checked(errcheck) c.AddFunc(*schedule, func() { ^ Signed-off-by: Mario Trangoni --- cmd/mtr-exporter/main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/mtr-exporter/main.go b/cmd/mtr-exporter/main.go index 69ddfa4..979628a 100644 --- a/cmd/mtr-exporter/main.go +++ b/cmd/mtr-exporter/main.go @@ -50,7 +50,8 @@ func main() { job := newMtrJob(*mtrBin, flag.Args()) c := cron.New() - c.AddFunc(*schedule, func() { + + _, err := c.AddFunc(*schedule, func() { log.Println("launching", job.cmdLine) if err := job.Launch(); err != nil { log.Println("failed:", err) @@ -59,6 +60,11 @@ func main() { log.Println("done: ", len(job.Report.Hubs), "hops in", job.Duration, ".") }) + if err != nil { + log.Fatalf(err.Error()) + os.Exit(1) + } + c.Start() http.Handle("/metrics", job)