Repository navigation
Description
Summary
sprintfbool (pkg/linters/sprintfbool, the newly-added 55th analyzer) flags fmt.Sprintf("%t", b) where b is a bool and rewrites it to strconv.FormatBool(b). On review it is one of the cleanest linters in the suite — it has already absorbed the lessons from prior sergo findings — and it has zero production violations, so it is enforce-ready but is not yet wired into CI (.github/workflows/cgo.yml:1208-1211 enforces 24 linters; sprintfbool is absent).
Correctness review — clean (prior-bug classes all avoided)
Checks that pass (with the sergo finding each corresponds to)
- Exact-type match, not
Underlying()—sprintfbool.go:112requiresargType == types.Typ[types.Bool]. Named bool types (type myBool bool) are correctly not flagged, becausestrconv.FormatBooltakes the predeclaredbooland a named type is not assignable — so the autofix always compiles. This is exactly the mistakewritebytestringmade (writebytestring (new 43rd linter): autofix emits non-compiling io.WriteString(w, s) for named string types + missing RunWithSugg [Content truncated due to length] #44187/writebytestring autofix references io.WriteString but never adds the "io" import — non-compiling fix when the file doesn't alrea [Content truncated due to length] #44653:t.Underlying()==Stringmatched named strings → non-compilingio.WriteString). FixturegoodNamedBool(testdata/.../sprintfbool.go:29) documents the intent. RunWithSuggestedFixes—sprintfbool_test.go:16uses RWSF (not plainanalysistest.Run), closing the verification-parity gap that Autofix verification-parity gap: 3 of 9 SuggestedFix linters (stringsindexcontains, sprintfint, stringreplaceminusone) have zero [Content truncated due to length] #43313 flagged for older linters.- Package identity via
astutil.IsPkgSelector—sprintfbool.go:93, not a syntacticsel.X.Name == "fmt"string match (the regression class from Linter precision (regression): the syntactic stdlib-package-match migration never landed — 5 holdouts remain, 3 CI-enforced (#40 [Content truncated due to length] #43934/Linter precision: migrate the 3 remaining CI-enforced linters that match stdlib packages by identifier name to astutil.IsPkgSele [Content truncated due to length] #40243). - Alias-safe autofix —
replacementForCall(sprintfbool.go:419) resolves the local binding viaastutil.ImportedAsand emits<localName>.FormatBool, and skips on./_imports and shadowing (QualifierShadowed, line 427). This avoids the hardcoded-default-qualifier bug filed for the siblings in Autofix import robustness: sprintfint/writebytestring/bytescomparestring key import-presence on the path but emit a hardcoded pa [Content truncated due to length] #45037. nolint+filecheckwired —Requiresincludes both (sprintfbool.go:36);//nolint:sprintfbooland generated-file skipping are honored and tested (suppressedfixture;shadow/comment_overlapfixtures cover the bail-outs).- Untyped literals handled —
fmt.Sprintf("%t", true)is flagged (default-typed tobool); fixturebadLiteral.
Enforce-readiness evidence
$ grep -rn 'Sprintf("%t"' pkg cmd internal | grep -v testdata
# only the linter's own doc/message strings match — ZERO production call sites
Zero production violations under the default build ⇒ adding sprintfbool to CI cannot break the build today and locks in the improvement going forward. This mirrors the accepted enforce-readiness issues #42644 (sprintfint), #45186 (stringsindexcontains), #45629, #46341.
Recommendation
Add -sprintfbool to both LINTER_FLAGS invocations in .github/workflows/cgo.yml (the default-build run at :1208 and the wasm run at :1211).
- run: make golint-custom LINTER_FLAGS="... -mapdeletecheck -test=false"
+ run: make golint-custom LINTER_FLAGS="... -mapdeletecheck -sprintfbool -test=false"Validation checklist
-
make golint-custom LINTER_FLAGS="-sprintfbool -test=false"reports zero findings on the default build. - Same under
GOOS=js GOARCH=wasmfor the wasmLINTER_PACKAGESset. -
-sprintfbooladded to bothcgo.ymlinvocations.
Effort: trivial (two-line CI edit) once verified. Optional companion cleanups (separate, lower priority): %v on a bool is an equivalent-but-intentionally-unflagged idiom (fixture goodOtherVerb) — leave as designed.
Generated by 🤖 Sergo - Serena Go Expert · 419.4 AIC · ⌖ 11.5 AIC · ⊞ 5.8K · ◷
- expires on Jul 27, 2026, 9:02 PM UTC-08:00
Activity
github-actions commentedon Jul 21, 2026
🍪 Issue Monster selected this for Copilot
I've identified this issue as a good candidate for automated resolution and requested assignment to the Copilot coding agent.
If assignment succeeds, the Copilot coding agent will analyze the issue and create a pull request with the fix.
Om nom nom! 🍪
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
pi.devSee Network Configuration for more information.