From 16f85a7ff268a4e26c78cf3c4202152a7a1d6d90 Mon Sep 17 00:00:00 2001 From: Sean Liao Date: Sun, 26 Oct 2025 13:59:06 +0000 Subject: [PATCH 1/3] all: eliminate vet diagnostics For golang/go#74011 Change-Id: Ib98bdd5ff547879d6695cec2f3cb40b52baac736 Reviewed-on: https://go-review.googlesource.com/c/text/+/714223 Reviewed-by: Dmitri Shuralyov Reviewed-by: Dmitri Shuralyov Reviewed-by: Junyang Shao LUCI-TryBot-Result: Go LUCI --- collate/collate.go | 1 - currency/currency_test.go | 4 ++-- date/tables.go | 2 +- encoding/ianaindex/ascii.go | 4 ++-- encoding/japanese/eucjp.go | 6 +++--- encoding/japanese/iso2022jp.go | 6 +++--- encoding/japanese/shiftjis.go | 6 +++--- encoding/korean/euckr.go | 6 +++--- encoding/simplifiedchinese/gbk.go | 20 ++++++++++---------- encoding/simplifiedchinese/hzgb2312.go | 6 +++--- encoding/traditionalchinese/big5.go | 6 +++--- encoding/unicode/unicode.go | 6 +++--- internal/cldrtree/generate.go | 2 +- internal/cldrtree/testdata/test1/output.go | 2 +- internal/cldrtree/testdata/test2/output.go | 2 +- internal/colltab/collelem.go | 2 -- unicode/cldr/resolve.go | 1 - 17 files changed, 39 insertions(+), 43 deletions(-) diff --git a/collate/collate.go b/collate/collate.go index d8c23cb69..449c73c8d 100644 --- a/collate/collate.go +++ b/collate/collate.go @@ -255,7 +255,6 @@ func (i *iter) nextPrimary() int { return 0 } } - panic("should not reach here") } func (i *iter) nextSecondary() int { diff --git a/currency/currency_test.go b/currency/currency_test.go index 6c05ecbf6..0ef8946ac 100644 --- a/currency/currency_test.go +++ b/currency/currency_test.go @@ -166,7 +166,7 @@ func getSize(t *testing.T, main string) int { } func BenchmarkString(b *testing.B) { - for i := 0; i < b.N; i++ { - USD.String() + for b.Loop() { + _ = USD.String() } } diff --git a/date/tables.go b/date/tables.go index 7432964a0..a5a45d285 100644 --- a/date/tables.go +++ b/date/tables.go @@ -4,7 +4,7 @@ package date import "golang.org/x/text/internal/cldrtree" -var tree = &cldrtree.Tree{locales, indices, buckets} +var tree = &cldrtree.Tree{Locales: locales, Indices: indices, Buckets: buckets} // Path values: // diff --git a/encoding/ianaindex/ascii.go b/encoding/ianaindex/ascii.go index 2b9824f82..c81454269 100644 --- a/encoding/ianaindex/ascii.go +++ b/encoding/ianaindex/ascii.go @@ -66,8 +66,8 @@ func (d asciiEncoder) Transform(dst, src []byte, atEOF bool) (nDst, nSrc int, er var asciiEnc = &internal.Encoding{ Encoding: &internal.SimpleEncoding{ - asciiDecoder{}, - asciiEncoder{}, + Decoder: asciiDecoder{}, + Encoder: asciiEncoder{}, }, Name: "US-ASCII", MIB: identifier.ASCII, diff --git a/encoding/japanese/eucjp.go b/encoding/japanese/eucjp.go index 79313fa58..6fce8c5f5 100644 --- a/encoding/japanese/eucjp.go +++ b/encoding/japanese/eucjp.go @@ -17,9 +17,9 @@ import ( var EUCJP encoding.Encoding = &eucJP var eucJP = internal.Encoding{ - &internal.SimpleEncoding{eucJPDecoder{}, eucJPEncoder{}}, - "EUC-JP", - identifier.EUCPkdFmtJapanese, + Encoding: &internal.SimpleEncoding{Decoder: eucJPDecoder{}, Encoder: eucJPEncoder{}}, + Name: "EUC-JP", + MIB: identifier.EUCPkdFmtJapanese, } type eucJPDecoder struct{ transform.NopResetter } diff --git a/encoding/japanese/iso2022jp.go b/encoding/japanese/iso2022jp.go index 613226df5..6f7bd460a 100644 --- a/encoding/japanese/iso2022jp.go +++ b/encoding/japanese/iso2022jp.go @@ -17,9 +17,9 @@ import ( var ISO2022JP encoding.Encoding = &iso2022JP var iso2022JP = internal.Encoding{ - internal.FuncEncoding{iso2022JPNewDecoder, iso2022JPNewEncoder}, - "ISO-2022-JP", - identifier.ISO2022JP, + Encoding: internal.FuncEncoding{Decoder: iso2022JPNewDecoder, Encoder: iso2022JPNewEncoder}, + Name: "ISO-2022-JP", + MIB: identifier.ISO2022JP, } func iso2022JPNewDecoder() transform.Transformer { diff --git a/encoding/japanese/shiftjis.go b/encoding/japanese/shiftjis.go index 16fd8a6e3..af65d43d9 100644 --- a/encoding/japanese/shiftjis.go +++ b/encoding/japanese/shiftjis.go @@ -18,9 +18,9 @@ import ( var ShiftJIS encoding.Encoding = &shiftJIS var shiftJIS = internal.Encoding{ - &internal.SimpleEncoding{shiftJISDecoder{}, shiftJISEncoder{}}, - "Shift JIS", - identifier.ShiftJIS, + Encoding: &internal.SimpleEncoding{Decoder: shiftJISDecoder{}, Encoder: shiftJISEncoder{}}, + Name: "Shift JIS", + MIB: identifier.ShiftJIS, } type shiftJISDecoder struct{ transform.NopResetter } diff --git a/encoding/korean/euckr.go b/encoding/korean/euckr.go index 034337f5d..81c834730 100644 --- a/encoding/korean/euckr.go +++ b/encoding/korean/euckr.go @@ -20,9 +20,9 @@ var All = []encoding.Encoding{EUCKR} var EUCKR encoding.Encoding = &eucKR var eucKR = internal.Encoding{ - &internal.SimpleEncoding{eucKRDecoder{}, eucKREncoder{}}, - "EUC-KR", - identifier.EUCKR, + Encoding: &internal.SimpleEncoding{Decoder: eucKRDecoder{}, Encoder: eucKREncoder{}}, + Name: "EUC-KR", + MIB: identifier.EUCKR, } type eucKRDecoder struct{ transform.NopResetter } diff --git a/encoding/simplifiedchinese/gbk.go b/encoding/simplifiedchinese/gbk.go index 0e0fabfd6..2f2fd5d44 100644 --- a/encoding/simplifiedchinese/gbk.go +++ b/encoding/simplifiedchinese/gbk.go @@ -22,21 +22,21 @@ var ( ) var gbk = internal.Encoding{ - &internal.SimpleEncoding{ - gbkDecoder{gb18030: false}, - gbkEncoder{gb18030: false}, + Encoding: &internal.SimpleEncoding{ + Decoder: gbkDecoder{gb18030: false}, + Encoder: gbkEncoder{gb18030: false}, }, - "GBK", - identifier.GBK, + Name: "GBK", + MIB: identifier.GBK, } var gbk18030 = internal.Encoding{ - &internal.SimpleEncoding{ - gbkDecoder{gb18030: true}, - gbkEncoder{gb18030: true}, + Encoding: &internal.SimpleEncoding{ + Decoder: gbkDecoder{gb18030: true}, + Encoder: gbkEncoder{gb18030: true}, }, - "GB18030", - identifier.GB18030, + Name: "GB18030", + MIB: identifier.GB18030, } type gbkDecoder struct { diff --git a/encoding/simplifiedchinese/hzgb2312.go b/encoding/simplifiedchinese/hzgb2312.go index e15b7bf6a..351750e60 100644 --- a/encoding/simplifiedchinese/hzgb2312.go +++ b/encoding/simplifiedchinese/hzgb2312.go @@ -17,9 +17,9 @@ import ( var HZGB2312 encoding.Encoding = &hzGB2312 var hzGB2312 = internal.Encoding{ - internal.FuncEncoding{hzGB2312NewDecoder, hzGB2312NewEncoder}, - "HZ-GB2312", - identifier.HZGB2312, + Encoding: internal.FuncEncoding{Decoder: hzGB2312NewDecoder, Encoder: hzGB2312NewEncoder}, + Name: "HZ-GB2312", + MIB: identifier.HZGB2312, } func hzGB2312NewDecoder() transform.Transformer { diff --git a/encoding/traditionalchinese/big5.go b/encoding/traditionalchinese/big5.go index 1fcddde08..5046920ee 100644 --- a/encoding/traditionalchinese/big5.go +++ b/encoding/traditionalchinese/big5.go @@ -20,9 +20,9 @@ var All = []encoding.Encoding{Big5} var Big5 encoding.Encoding = &big5 var big5 = internal.Encoding{ - &internal.SimpleEncoding{big5Decoder{}, big5Encoder{}}, - "Big5", - identifier.Big5, + Encoding: &internal.SimpleEncoding{Decoder: big5Decoder{}, Encoder: big5Encoder{}}, + Name: "Big5", + MIB: identifier.Big5, } type big5Decoder struct{ transform.NopResetter } diff --git a/encoding/unicode/unicode.go b/encoding/unicode/unicode.go index dd99ad14d..ce28c9062 100644 --- a/encoding/unicode/unicode.go +++ b/encoding/unicode/unicode.go @@ -60,9 +60,9 @@ func (utf8bomEncoding) NewDecoder() *encoding.Decoder { } var utf8enc = &internal.Encoding{ - &internal.SimpleEncoding{utf8Decoder{}, runes.ReplaceIllFormed()}, - "UTF-8", - identifier.UTF8, + Encoding: &internal.SimpleEncoding{Decoder: utf8Decoder{}, Encoder: runes.ReplaceIllFormed()}, + Name: "UTF-8", + MIB: identifier.UTF8, } type utf8bomDecoder struct { diff --git a/internal/cldrtree/generate.go b/internal/cldrtree/generate.go index 4f00f6d92..24db8b3d8 100644 --- a/internal/cldrtree/generate.go +++ b/internal/cldrtree/generate.go @@ -19,7 +19,7 @@ func generate(b *Builder, t *Tree, w *gen.CodeWriter) error { fmt.Fprintln(w, `import "golang.org/x/text/internal/cldrtree"`) fmt.Fprintln(w) - fmt.Fprintf(w, "var tree = &cldrtree.Tree{locales, indices, buckets}\n\n") + fmt.Fprintf(w, "var tree = &cldrtree.Tree{Locales: locales, Indices: indices, Buckets: buckets}\n\n") w.WriteComment("Path values:\n%s", b.stats()) fmt.Fprintln(w) diff --git a/internal/cldrtree/testdata/test1/output.go b/internal/cldrtree/testdata/test1/output.go index 367fc70fb..0c8e6f660 100644 --- a/internal/cldrtree/testdata/test1/output.go +++ b/internal/cldrtree/testdata/test1/output.go @@ -4,7 +4,7 @@ package test import "golang.org/x/text/internal/cldrtree" -var tree = &cldrtree.Tree{locales, indices, buckets} +var tree = &cldrtree.Tree{Locales: locales, Indices: indices, Buckets: buckets} // Path values: // diff --git a/internal/cldrtree/testdata/test2/output.go b/internal/cldrtree/testdata/test2/output.go index 63d6d9620..d857924bf 100644 --- a/internal/cldrtree/testdata/test2/output.go +++ b/internal/cldrtree/testdata/test2/output.go @@ -4,7 +4,7 @@ package test import "golang.org/x/text/internal/cldrtree" -var tree = &cldrtree.Tree{locales, indices, buckets} +var tree = &cldrtree.Tree{Locales: locales, Indices: indices, Buckets: buckets} // Path values: // diff --git a/internal/colltab/collelem.go b/internal/colltab/collelem.go index bdcae9b13..1757efc8f 100644 --- a/internal/colltab/collelem.go +++ b/internal/colltab/collelem.go @@ -71,8 +71,6 @@ func (ce Elem) ctype() ceType { } return ceDecompose } - panic("should not reach here") - return ceType(-1) } // For normal collation elements, we assume that a collation element either has diff --git a/unicode/cldr/resolve.go b/unicode/cldr/resolve.go index 31cc7be38..814f03889 100644 --- a/unicode/cldr/resolve.go +++ b/unicode/cldr/resolve.go @@ -158,7 +158,6 @@ func walkXPath(e Elem, path string) (res Elem, err error) { if c == ".." { if e = e.enclosing(); e == nil { panic("path ..") - return nil, fmt.Errorf(`cldr: ".." moves past root in path %q`, path) } continue } else if c == "" { From 087616b6cde9434a9f6f788f4fe975b40651be26 Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Fri, 28 Nov 2025 13:07:39 -0500 Subject: [PATCH 2/3] transform: fix %q verb use with wrong type Caught early by the improved vet check gated behind the 1.26 language version combined with a tiplang builder that tests with 1.26 language version. Change-Id: If22c0f81d35d7266f05bf5481439db46ea889b25 Cq-Include-Trybots: luci.golang.try:x_text-gotip-linux-amd64-tiplang Reviewed-on: https://go-review.googlesource.com/c/text/+/725061 Auto-Submit: Alan Donovan Auto-Submit: Dmitri Shuralyov Reviewed-by: Dmitri Shuralyov Reviewed-by: Alan Donovan LUCI-TryBot-Result: Go LUCI Commit-Queue: Alan Donovan --- transform/transform_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transform/transform_test.go b/transform/transform_test.go index 1ce36c812..3e63536f9 100644 --- a/transform/transform_test.go +++ b/transform/transform_test.go @@ -733,7 +733,7 @@ func TestDiscard(t *testing.T) { for i, tc := range testCases { nDst, nSrc, err := Discard.Transform(make([]byte, tc.dstSize), []byte(tc.str), true) if nDst != 0 || nSrc != len(tc.str) || err != nil { - t.Errorf("%d:\ngot %q, %d, %v\nwant 0, %d, nil", i, nDst, nSrc, err, len(tc.str)) + t.Errorf("%d:\ngot %d, %d, %v\nwant 0, %d, nil", i, nDst, nSrc, err, len(tc.str)) } } } From 0dd57a6ef90c283b902525213f15d6b2a59cc84b Mon Sep 17 00:00:00 2001 From: Gopher Robot Date: Mon, 8 Dec 2025 04:02:30 -0800 Subject: [PATCH 3/3] go.mod: update golang.org/x dependencies Update golang.org/x dependencies to their latest tagged versions. Change-Id: I22f39c618b0287a37b6844c5ed0d8b0c5ebf69e9 Reviewed-on: https://go-review.googlesource.com/c/text/+/728001 Reviewed-by: David Chase Reviewed-by: Dmitri Shuralyov Auto-Submit: Gopher Robot LUCI-TryBot-Result: Go LUCI --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index 7e7eddb1c..0f1f7cb1f 100644 --- a/go.mod +++ b/go.mod @@ -2,9 +2,9 @@ module golang.org/x/text go 1.24.0 -require golang.org/x/tools v0.38.0 // tagx:ignore +require golang.org/x/tools v0.39.0 // tagx:ignore require ( - golang.org/x/mod v0.29.0 // indirect; tagx:ignore - golang.org/x/sync v0.18.0 // indirect + golang.org/x/mod v0.30.0 // indirect; tagx:ignore + golang.org/x/sync v0.19.0 // indirect ) diff --git a/go.sum b/go.sum index 88874e9ab..db304fa2d 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA= -golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w= -golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= -golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= -golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ= -golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs= +golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk= +golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc= +golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= +golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/tools v0.39.0 h1:ik4ho21kwuQln40uelmciQPp9SipgNDdrafrYA4TmQQ= +golang.org/x/tools v0.39.0/go.mod h1:JnefbkDPyD8UU2kI5fuf8ZX4/yUeh9W877ZeBONxUqQ=