mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/internal/obj: fix Link.Diag printf errors
go1.26's vet printf checker can associate the printf-wrapper property with local vars and struct fields if they are assigned from a printf-like func literal (CL 706635). This leads to better detection of mistakes. Change-Id: I604be1e200aa1aba75e09d4f36ab68c1dba3b8a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/710195 Auto-Submit: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
e1ca1de123
commit
d4830c6130
7 changed files with 15 additions and 8 deletions
|
|
@ -1216,6 +1216,13 @@ type Link struct {
|
|||
Fingerprint goobj.FingerprintType // fingerprint of symbol indices, to catch index mismatch
|
||||
}
|
||||
|
||||
// Assert to vet's printf checker that Link.DiagFunc is a printf-like.
|
||||
func _(ctxt *Link) {
|
||||
ctxt.DiagFunc = func(format string, args ...any) {
|
||||
_ = fmt.Sprintf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func (ctxt *Link) Diag(format string, args ...interface{}) {
|
||||
ctxt.Errors++
|
||||
ctxt.DiagFunc(format, args...)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue