From f63131120b02a174d7ef83e4732a99201fae3d6b Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Wed, 23 Sep 2026 17:04:25 +0800 Subject: [PATCH 1/3] =?UTF-8?q?fix=F0=9F=90=9B:=20print=20the=20server=20n?= =?UTF-8?q?ame,=20not=20%!S(string=3D...),=20on=20shutdown=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- server/listener/server.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/listener/server.go b/server/listener/server.go index f4fc1f29..31b6b189 100644 --- a/server/listener/server.go +++ b/server/listener/server.go @@ -120,7 +120,7 @@ func (e *Server) Start(ctx context.Context) error { <-ctx.Done() err = e.Shutdown(ctx) if err != nil { - log.Errorf("%S Server shutdown error: %s", e.name, err.Error()) + log.Errorf("%s Server shutdown error: %s", e.name, err.Error()) } }() if e.opts.startedHook != nil { From 01894b028008e319f50e4648c1ede9a5914551dc Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Wed, 23 Sep 2026 17:07:03 +0800 Subject: [PATCH 2/3] =?UTF-8?q?refactor=E2=99=BB=EF=B8=8F:=20render=20the?= =?UTF-8?q?=20message=20at=20Log=20and=20Logf,=20not=20inside=20a=20shared?= =?UTF-8?q?=20helper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- logger/default.go | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/logger/default.go b/logger/default.go index 30ac98fd..3ca3ab2b 100644 --- a/logger/default.go +++ b/logger/default.go @@ -92,22 +92,37 @@ func logCallerfilePath(loggingFilePath string) string { // Log 记录日志条目 // Log logs a log entry func (l *defaultLogger) Log(level Level, v ...interface{}) { - l.logf(level, "", v...) + if !l.opts.Level.Enabled(level) { + return + } + l.emit(level, fmt.Sprint(v...)) } // Logf 记录格式化的日志条目 // Logf logs a formatted log entry func (l *defaultLogger) Logf(level Level, format string, v ...interface{}) { - l.logf(level, format, v...) -} - -// logf 记录日志条目 -// logf logs a log entry -func (l *defaultLogger) logf(level Level, format string, v ...interface{}) { if !l.opts.Level.Enabled(level) { return } + l.emit(level, fmt.Sprintf(format, v...)) +} +// emit writes one already-rendered message. +// +// The two callers above render the message themselves rather than handing a +// format string and its arguments down here, for two reasons. go vet reads any +// function that forwards both to fmt.Sprintf as a printf wrapper, and then +// reports Log's empty format string as a call "with arguments but no +// formatting directives" - which is precisely what Log is, deliberately, being +// the unformatted entry point. And rendering at the caller keeps that work +// behind the caller's Enabled check, which is where it was before. +// +// emit must stay exactly one frame below Log and Logf. Options.CallerSkipCount +// is counted outwards from the runtime.Caller call below, so adding or removing +// a frame here silently moves every file:line this logger computes. +// +// Callers are responsible for the Enabled check; emit does not repeat it. +func (l *defaultLogger) emit(level Level, message string) { l.RLock() fields := copyFields(l.opts.Fields) l.RUnlock() @@ -119,11 +134,7 @@ func (l *defaultLogger) logf(level Level, format string, v ...interface{}) { rec := dlog.Record{ Timestamp: time.Now(), Metadata: make(map[string]string, len(fields)), - } - if format == "" { - rec.Message = fmt.Sprint(v...) - } else { - rec.Message = fmt.Sprintf(format, v...) + Message: message, } for k, v := range fields { From efc199e2079ea110fef71901ab5cc53572c65a44 Mon Sep 17 00:00:00 2001 From: zhangwenjian Date: Wed, 23 Sep 2026 17:10:58 +0800 Subject: [PATCH 3/3] =?UTF-8?q?chore=E2=AC=86=EF=B8=8F:=20build=20with=20G?= =?UTF-8?q?o=201.27,=20and=20move=20staticcheck=20up=20with=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- Makefile | 2 +- go.mod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d231c2c3..127a7ba7 100644 --- a/Makefile +++ b/Makefile @@ -24,7 +24,7 @@ test-race: # a gate. Analysed for the host and for linux: a file behind a build tag is # invisible to a run on another platform, which is how a finding in # watcher_linux.go stayed hidden from every local run and failed in CI. -STATICCHECK ?= honnef.co/go/tools/cmd/staticcheck@v0.7.0 +STATICCHECK ?= honnef.co/go/tools/cmd/staticcheck@v0.8.1 # bench runs every benchmark once, briefly. It is a smoke test that the # benchmarks still compile and run - not a measurement. For numbers worth diff --git a/go.mod b/go.mod index 9345ace4..b173190e 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/go-admin-team/go-admin-core/v2 -go 1.25.13 +go 1.27.1 require ( dario.cat/mergo v1.0.2