Repository navigation
Build with Go 1.27, and fix the two vet findings it surfaces - #159
Merged
Merged
Conversation
The verb was %S, which fmt does not define, so the line rendered as "%!S(string=http) Server shutdown error: ..." - the name that was meant to identify which listener failed came out as an error marker instead. The line directly above it, on the start path, already used %s. go vet reports this, but only from Go 1.26 onward; under the toolchain this module currently declares it goes unreported.
…elper logf took a format string and its arguments and chose between fmt.Sprint and fmt.Sprintf, which is what makes a function a printf wrapper in go vet's reading. Log, the unformatted entry point, then called it with an empty format string and arguments, and from Go 1.26 onward vet reports that call as having "arguments but no formatting directives". The empty string was deliberate - logf branched on it - so there was nothing wrong at the call site; the shape of logf was what invited the report. Log and Logf now render their own message and hand emit the finished string. emit sits exactly where logf did, one frame below both callers, so Options.CallerSkipCount still resolves to the same frame. Verified rather than assumed: printing runtime.Caller's result from inside both the old and the new version, through both entry points, gives the identical frame. Rendering moved behind each caller's Enabled check, which is where it already happened.
The module declared go 1.25.13, which is two releases behind and no longer
receives security fixes. Two things had already broken against it:
- govulncheck's module now requires Go 1.26 or newer, so the job that runs
it failed while downloading the tool, before reading a line of this
repository. The red looked like a vulnerability report and was not one.
- the printf checks Go 1.26 strengthened were never running here, which is
why the %S verb fixed two commits ago went unreported for as long as it
did.
1.27.1 rather than the 1.26.5 the applications built on this declare:
govulncheck reports six standard-library vulnerabilities against go1.26.5
that this code reaches (net/http among them, fixed in go1.26.6), and none
against go1.27.1.
staticcheck moves from v0.7.0 to v0.8.1 in this commit rather than its own:
v0.7.0 cannot read Go 1.27's export data ("export data version 4 is greater
than maximum supported version 2") and fails on every package, so a commit
raising only the language version would not lint clean.
go mod tidy leaves go.sum untouched - no dependency's requirements move with
this.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The job that runs govulncheck has been failing since govulncheck's own module started requiring Go 1.26, while this module declares
go 1.25.13. It fails while downloading the tool, before a line of this repository is read, so the red never was a vulnerability report.Raising the language version fixes that, and switches on the printf checks Go 1.26 strengthened. Those found two things.
The
%Sverbserver/listenerlogged a shutdown error with%S, which fmt does not define. The line rendered as%!S(string=http) Server shutdown error: ...— the listener name meant to say which server failed came out as an error marker instead. The line directly above it, on the start path, already used%s.Logcalling a printf wrapper with an empty formatdefaultLogger.logftook a format string and its arguments and chose betweenfmt.Sprintandfmt.Sprintf, which is what makes a function a printf wrapper in vet's reading.Log, the unformatted entry point, called it with""and arguments, and vet reports that as "arguments but no formatting directives".The empty string was deliberate —
logfbranched on it — so there was nothing wrong at the call site; the shape oflogfwas what invited the report.LogandLogfnow render their own message and handemita finished string.emitsits exactly wherelogfdid, one frame below both callers, becauseOptions.CallerSkipCountis counted outwards from theruntime.Callercall inside it. Verified rather than assumed: printingruntime.Caller's result from inside both the old and the new version, through both entry points, gives the identical frame.Why 1.27.1 and not 1.26
govulncheck reports six standard-library vulnerabilities against
go1.26.5that this code actually reaches —net/httpamong them, fixed ingo1.26.6— and none againstgo1.27.1.staticcheck
v0.7.0 cannot read Go 1.27's export data (
export data version 4 is greater than maximum supported version 2) and fails on every package, so it moves to v0.8.1 in the same commit as the language version. A commit raising only one of the two would not lint clean.Two things found here and deliberately not fixed
defaultLoggercomputesfields["file"]fromruntime.Calleron every error-level line and stores it in the record's metadata, which nothing reads — the output line is built from name, timestamp, level and message alone. The work is done and discarded on every error log.And the default
CallerSkipCountof 3 does not resolve to the caller for this logger; it lands one frame past it.zap.goandlogrus.goboth override it to 2. Neither is observable today precisely because the result is discarded, and both would surface the moment that metadata is wired to the output. Fixing them belongs with whatever change does that wiring.Checks
make ciandmake vulnboth pass.go mod tidyleavesgo.sumuntouched — no dependency's requirements move with this.For downstream
Applications built on this module that declare
go 1.26.5will need to raise their own language version before taking this release.