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 <noreply@anthropic.com>
This commit is contained in:
Feng Ruohang
2026-08-06 19:09:26 +08:00
parent b6d47b739c
commit 9462cce16e
+4 -3
View File
@@ -285,15 +285,16 @@ func healthcheckMain(ctx *cli.Context) {
res := probeHealth(baseURL, check, ctx.Bool("maintenance"), timeout) res := probeHealth(baseURL, check, ctx.Bool("maintenance"), timeout)
quiet := ctx.Bool("quiet") || ctx.GlobalBool("quiet") 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) buf, jerr := json.Marshal(res)
if jerr != nil { if jerr != nil {
fail("%v", jerr) fail("%v", jerr)
} }
fmt.Println(string(buf)) fmt.Println(string(buf))
} else if !res.Healthy { case !res.Healthy:
fmt.Fprintln(os.Stderr, res.line()) fmt.Fprintln(os.Stderr, res.line())
} else if !quiet { case !quiet:
fmt.Println(res.line()) fmt.Println(res.line())
} }