Why
internal/report's package comment, written when the package was split out in #491, says:
Nothing here writes to stdout or decides an exit code; it takes results and returns text,
which is what makes it testable.
report.go:192 calls os.Exit(1), inside JSON(), on a marshal failure.
The comment is mine, and so is the os.Exit. It was named in #585's description as "the
one piece of entanglement left in the package" and deliberately left — then the package
comment was written claiming the opposite. A reader has no way to tell which is true
without grepping.
What to do
Two coherent options, and the choice matters more than the line:
- Make the comment true.
JSON returns the marshal error, the caller decides. Its
signature becomes (string, bool, error) — or the error folds into the bool with the
message in the string, which is uglier but keeps the shape. Render and both call sites
follow.
- Make the comment honest. Keep the exit, and say why: the failure is documented as
impossible ("every field is a plain Go value"), and an empty report would be worse than a
loud death.
Option 1 is the one that matches what the package is for. Option 2 is defensible only if
the exit is genuinely unreachable — in which case the honest form is a panic with a message,
not an exit, since an unreachable branch that exits looks like a decision.
Validation
- Whichever way:
grep -n "os.Exit" internal/report/ and the package comment agree.
- The JSON report still ends with a newline and still redacts, which its tests cover.
Why
internal/report's package comment, written when the package was split out in #491, says:report.go:192callsos.Exit(1), insideJSON(), on a marshal failure.The comment is mine, and so is the
os.Exit. It was named in #585's description as "theone piece of entanglement left in the package" and deliberately left — then the package
comment was written claiming the opposite. A reader has no way to tell which is true
without grepping.
What to do
Two coherent options, and the choice matters more than the line:
JSONreturns the marshal error, the caller decides. Itssignature becomes
(string, bool, error)— or the error folds into the bool with themessage in the string, which is uglier but keeps the shape.
Renderand both call sitesfollow.
impossible ("every field is a plain Go value"), and an empty report would be worse than a
loud death.
Option 1 is the one that matches what the package is for. Option 2 is defensible only if
the exit is genuinely unreachable — in which case the honest form is a panic with a message,
not an exit, since an unreachable branch that exits looks like a decision.
Validation
grep -n "os.Exit" internal/report/and the package comment agree.