From 9462cce16e102e253151ce474bfd09327d67815c Mon Sep 17 00:00:00 2001 From: Feng Ruohang Date: Thu, 6 Aug 2026 19:09:26 +0800 Subject: [PATCH] fix: rewrite the healthcheck output selection as a switch gocritic's ifElseChain check fails make lint on the --json/--quiet branch introduced by b6d47b739; the quality job runs make lint on every push to main. Behavior is unchanged (verified by re-running the json/quiet success and failure cases byte-for-byte). Co-Authored-By: Claude Fable 5 --- cmd/healthcheck-main.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/healthcheck-main.go b/cmd/healthcheck-main.go index f58a74cff..b958685aa 100644 --- a/cmd/healthcheck-main.go +++ b/cmd/healthcheck-main.go @@ -285,15 +285,16 @@ func healthcheckMain(ctx *cli.Context) { res := probeHealth(baseURL, check, ctx.Bool("maintenance"), timeout) quiet := ctx.Bool("quiet") || ctx.GlobalBool("quiet") - if ctx.Bool("json") || ctx.GlobalBool("json") { + switch { + case ctx.Bool("json") || ctx.GlobalBool("json"): buf, jerr := json.Marshal(res) if jerr != nil { fail("%v", jerr) } fmt.Println(string(buf)) - } else if !res.Healthy { + case !res.Healthy: fmt.Fprintln(os.Stderr, res.line()) - } else if !quiet { + case !quiet: fmt.Println(res.line()) }