From: Alan Donovan Date: Fri, 14 Nov 2025 19:59:36 +0000 (-0500) Subject: std: fix printf("%q", int) mistakes X-Git-Tag: go1.26rc1~271 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=aea881230d;p=gostls13.git std: fix printf("%q", int) mistakes For #72850 Change-Id: I07e64f05c82a34b1dadb9a72e16f5045e68cbd24 Reviewed-on: https://go-review.googlesource.com/c/go/+/720642 Auto-Submit: Alan Donovan Reviewed-by: Dmitri Shuralyov Reviewed-by: Dmitri Shuralyov LUCI-TryBot-Result: Go LUCI --- diff --git a/src/cmd/compile/internal/ir/fmt.go b/src/cmd/compile/internal/ir/fmt.go index ae4ff62652..eb64cce47b 100644 --- a/src/cmd/compile/internal/ir/fmt.go +++ b/src/cmd/compile/internal/ir/fmt.go @@ -574,7 +574,7 @@ func exprFmt(n Node, s fmt.State, prec int) { // Special case for rune constants. if typ == types.RuneType || typ == types.UntypedRune { if x, ok := constant.Uint64Val(val); ok && x <= utf8.MaxRune { - fmt.Fprintf(s, "%q", x) + fmt.Fprintf(s, "%q", rune(x)) return } } diff --git a/src/cmd/vet/testdata/print/print.go b/src/cmd/vet/testdata/print/print.go index 3761da420b..9145c12fb8 100644 --- a/src/cmd/vet/testdata/print/print.go +++ b/src/cmd/vet/testdata/print/print.go @@ -75,7 +75,7 @@ func PrintfTests() { fmt.Printf("%b %b %b %b", 3e9, x, fslice, c) fmt.Printf("%o %o", 3, i) fmt.Printf("%p", p) - fmt.Printf("%q %q %q %q", 3, i, 'x', r) + fmt.Printf("%q %q %q", rune(3), 'x', r) fmt.Printf("%s %s %s", "hi", s, []byte{65}) fmt.Printf("%t %t", true, b) fmt.Printf("%T %T", 3, i) diff --git a/src/crypto/rsa/equal_test.go b/src/crypto/rsa/equal_test.go index 435429c3d1..39a9cdc86c 100644 --- a/src/crypto/rsa/equal_test.go +++ b/src/crypto/rsa/equal_test.go @@ -21,7 +21,7 @@ func TestEqual(t *testing.T) { t.Errorf("public key is not equal to itself: %v", public) } if !public.Equal(crypto.Signer(private).Public().(*rsa.PublicKey)) { - t.Errorf("private.Public() is not Equal to public: %q", public) + t.Errorf("private.Public() is not Equal to public: %v", public) } if !private.Equal(private) { t.Errorf("private key is not equal to itself: %v", private) diff --git a/src/crypto/tls/bogo_shim_test.go b/src/crypto/tls/bogo_shim_test.go index 8f171d9259..02a943c13c 100644 --- a/src/crypto/tls/bogo_shim_test.go +++ b/src/crypto/tls/bogo_shim_test.go @@ -461,7 +461,7 @@ func bogoShim() { } if *expectVersion != 0 && cs.Version != uint16(*expectVersion) { - log.Fatalf("expected ssl version %q, got %q", uint16(*expectVersion), cs.Version) + log.Fatalf("expected ssl version %d, got %d", *expectVersion, cs.Version) } if *declineALPN && cs.NegotiatedProtocol != "" { log.Fatal("unexpected ALPN protocol") diff --git a/src/database/sql/fakedb_test.go b/src/database/sql/fakedb_test.go index 003e6c6298..e5f0459303 100644 --- a/src/database/sql/fakedb_test.go +++ b/src/database/sql/fakedb_test.go @@ -969,7 +969,7 @@ func (s *fakeStmt) QueryContext(ctx context.Context, args []driver.NamedValue) ( idx := t.columnIndex(wcol.Column) if idx == -1 { t.mu.Unlock() - return nil, fmt.Errorf("fakedb: invalid where clause column %q", wcol) + return nil, fmt.Errorf("fakedb: invalid where clause column %v", wcol) } tcol := trow.cols[idx] if bs, ok := tcol.([]byte); ok { diff --git a/src/fmt/scan_test.go b/src/fmt/scan_test.go index a4f80c23c2..ff9e4f30ca 100644 --- a/src/fmt/scan_test.go +++ b/src/fmt/scan_test.go @@ -998,7 +998,7 @@ func TestScanStateCount(t *testing.T) { t.Errorf("bad scan rune: %q %q %q should be '1' '2' '➂'", a.rune, b.rune, c.rune) } if a.size != 1 || b.size != 1 || c.size != 3 { - t.Errorf("bad scan size: %q %q %q should be 1 1 3", a.size, b.size, c.size) + t.Errorf("bad scan size: %d %d %d should be 1 1 3", a.size, b.size, c.size) } } diff --git a/src/internal/pkgbits/pkgbits_test.go b/src/internal/pkgbits/pkgbits_test.go index a4755bd35a..f67267189f 100644 --- a/src/internal/pkgbits/pkgbits_test.go +++ b/src/internal/pkgbits/pkgbits_test.go @@ -28,7 +28,7 @@ func TestRoundTrip(t *testing.T) { r := pr.NewDecoder(pkgbits.SectionMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic) if r.Version() != w.Version() { - t.Errorf("Expected reader version %q to be the writer version %q", r.Version(), w.Version()) + t.Errorf("Expected reader version %d to be the writer version %d", r.Version(), w.Version()) } } } diff --git a/src/os/os_test.go b/src/os/os_test.go index 536734901b..29f2e6d3b2 100644 --- a/src/os/os_test.go +++ b/src/os/os_test.go @@ -1192,7 +1192,7 @@ func TestRenameCaseDifference(pt *testing.T) { } if dirNamesLen := len(dirNames); dirNamesLen != 1 { - t.Fatalf("unexpected dirNames len, got %q, want %q", dirNamesLen, 1) + t.Fatalf("unexpected dirNames len, got %d, want %d", dirNamesLen, 1) } if dirNames[0] != to { diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index 8509f00a5e..30ec3fad51 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -6807,7 +6807,7 @@ func TestMakeFuncStackCopy(t *testing.T) { ValueOf(&concrete).Elem().Set(fn) x := concrete(nil, 7) if x != 9 { - t.Errorf("have %#q want 9", x) + t.Errorf("have %d want 9", x) } }