Skip to content

Build with Go 1.27, and fix the two vet findings it surfaces - #159

Merged
wenjianzhang merged 3 commits into
mainfrom
fix/go-1.27-and-vet-findings
Sep 23, 2026
Merged

wenjianzhang merged 3 commits into
mainfrom
fix/go-1.27-and-vet-findings

Conversation

@wenjianzhang

Copy link
Copy Markdown
Member

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 %S verb

server/listener logged 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.

Log calling a printf wrapper with an empty format

defaultLogger.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 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 — 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 a finished string.

emit sits exactly where logf did, one frame below both callers, because Options.CallerSkipCount is counted outwards from the runtime.Caller call inside it. 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.

Why 1.27.1 and not 1.26

govulncheck reports six standard-library vulnerabilities against go1.26.5 that this code actually reaches — net/http among them, fixed in go1.26.6 — and none against go1.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

defaultLogger computes fields["file"] from runtime.Caller on 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 CallerSkipCount of 3 does not resolve to the caller for this logger; it lands one frame past it. zap.go and logrus.go both 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 ci and make vuln both pass. go mod tidy leaves go.sum untouched — no dependency's requirements move with this.

For downstream

Applications built on this module that declare go 1.26.5 will need to raise their own language version before taking this release.

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.
Copilot AI lite review requested due to automatic review settings September 23, 2026 09:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@wenjianzhang
wenjianzhang merged commit 18ec8f9 into main Sep 23, 2026
5 checks passed
@wenjianzhang
wenjianzhang deleted the fix/go-1.27-and-vet-findings branch September 23, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants