From ec2ed9db85ce45df1ca8bfc1233848d49e88dfbc Mon Sep 17 00:00:00 2001 From: Paul Herman Date: Tue, 27 Aug 2024 13:09:20 +0200 Subject: [PATCH] Replace log.Fatalf with log.Exitf to avoid spamming stderr. (#1284) * Replace log.Fatalf with log.Exitf to avoid spamming stderr. The set of warnings is something that is changing over time. As scripts tend to hardcode these, they get out of date and we hit this unexpected warning code path. There's little benefit of having a stack trace from this issue. Thus, it's more convenient to just print the error itself and nothing else. * Update warn.go --- warn/warn.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/warn/warn.go b/warn/warn.go index 8d299de80..6f7c24e51 100644 --- a/warn/warn.go +++ b/warn/warn.go @@ -336,7 +336,8 @@ func FileWarnings(f *build.File, enabledWarnings []string, formatted *[]byte, mo } else if fct, ok := RuleWarningMap[warn]; ok { findings = append(findings, runWarningsFunction(warn, f, ruleWarningWrapper(fct), formatted, mode, fileReader)...) } else { - log.Fatalf("unexpected warning %q", warn) + log.Printf("unexpected warning %q", warn) + os.Exit(1) } } sort.Slice(findings, func(i, j int) bool { return findings[i].Start.Line < findings[j].Start.Line })