aboutsummaryrefslogtreecommitdiff
path: root/src/encoding
AgeCommit message (Collapse)Author
2024-10-02encoding/json: add omitzero optionJes Cok
Fixes #45669 Change-Id: Ic13523c0b3acdfc5b3e29a717bc62fde302ed8fd GitHub-Last-Rev: 57030f26b0062fa8eda21b3a73b7665deab88c76 GitHub-Pull-Request: golang/go#69622 Reviewed-on: https://go-review.googlesource.com/c/go/+/615676 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-09-23encoding/asn1: unmarshal bool values correctly dealing with the ANY typeJes Cok
Fixes #68241 Change-Id: I1ee81aa50c2f39f535ad27309e855f19acb2f2ea Reviewed-on: https://go-review.googlesource.com/c/go/+/595796 Auto-Submit: Roland Shoemaker <roland@golang.org> Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Roland Shoemaker <roland@golang.org>
2024-09-13encoding/gob: make use of maps.CloneJes Cok
Change-Id: I6a23219a9e05350bdd9205e19165d5944f15de31 GitHub-Last-Rev: 8c295bf55feaa07cd487e6015029c4682a1480b0 GitHub-Pull-Request: golang/go#69429 Reviewed-on: https://go-review.googlesource.com/c/go/+/612719 Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-09-05encoding/gob: cover missed cases when checking ignore depthRoland Shoemaker
This change makes sure that we are properly checking the ignored field recursion depth in decIgnoreOpFor consistently. This prevents stack exhaustion when attempting to decode a message that contains an extremely deeply nested struct which is ignored. Thanks to Md Sakib Anwar of The Ohio State University (anwar.40@osu.edu) for reporting this issue. Fixes #69139 Fixes CVE-2024-34156 Change-Id: Iacce06be95a5892b3064f1c40fcba2e2567862d6 Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1440 Reviewed-by: Russ Cox <rsc@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/611239 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2024-09-04encoding/xml: allow ]]> in attribute valuesDemi Marie Obenour
This is permitted by the XML specification. Fixes #68387 Change-Id: Ic4ab5520a08a5a997f1c3d13c6d5f80c0521e45c GitHub-Last-Rev: 6d2ac307bbd0ba7d50830ad8b879c00cc3a7242b GitHub-Pull-Request: golang/go#69197 Reviewed-on: https://go-review.googlesource.com/c/go/+/610056 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-09-03encoding/json: add embedded structs to the UnmarshalTypeError's Fieldj2gg0s
Including embedded struct inforamtion in error message. Fixes #68941 Change-Id: I6a6f7d506104839a9a7cf1a2c3003272f5534a79 GitHub-Last-Rev: 717f680acafd3f6509c0495f9092e028be502750 GitHub-Pull-Request: golang/go#68966 Reviewed-on: https://go-review.googlesource.com/c/go/+/606956 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-08-30encoding/base32, encoding/base64: document Decode to short bufferIan Lance Taylor
Document that if one of the Decode methods in these packages is given a short buffer, it panics. Fixes #69024 Change-Id: I1c0e4c74274965c1cfa0422cc8f86af4fefb1d00 Reviewed-on: https://go-review.googlesource.com/c/go/+/607499 Auto-Submit: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-08-15encoding/json: merge FieldStack if the error's Field exists.j2gg0s
When people return UnmarshalTypeError in UnmarshalJSON, we should append error's Field to FieldStack. Fixes #68750 Change-Id: I0a5a9b259a1b569de1bebc815ec936c913e10469 GitHub-Last-Rev: 18796addc3fa0d367ba1a3f4bd268ca246890fe0 GitHub-Pull-Request: golang/go#68870 Reviewed-on: https://go-review.googlesource.com/c/go/+/605455 Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-07-30encoding: add TextAppender and BinaryAppenderMateusz Poliwczak
For #62384 Change-Id: I54707a29653df72ad9cd5633f434b87e0f630b94 GitHub-Last-Rev: 4f78947ac563d78f862c5c8de1c2e1578a8d6e08 GitHub-Pull-Request: golang/go#68620 Reviewed-on: https://go-review.googlesource.com/c/go/+/601595 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-07-25encoding/gob: fix package doc typo for wireTypeChen Su
Change-Id: Ib93f2b565e5271dfa3c3ca5d040ef24269c47cf8 GitHub-Last-Rev: 3f1da518a404f5459e38f34427ae9177fe68f51e GitHub-Pull-Request: golang/go#68584 Reviewed-on: https://go-review.googlesource.com/c/go/+/601036 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-07-25encoding: use slices and maps to clean up testsapocelipes
Replace reflect.DeepEqual with slices.Equal/maps.Equal, which is much faster. Change-Id: I62ad60a66e28cfb2bb49c36037bafd4b9d201e88 GitHub-Last-Rev: 79554baddb1856260a44ba6587c205d223a527b1 GitHub-Pull-Request: golang/go#67611 Reviewed-on: https://go-review.googlesource.com/c/go/+/587818 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-07-24encoding/json: rewrite interface{} to anyIan Lance Taylor
For #49884 Change-Id: I1623201c47c820a152773d2f43d0072a1466d3bf Reviewed-on: https://go-review.googlesource.com/c/go/+/588118 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Auto-Submit: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2024-07-23encoding/binary: add missing test helper callsMartin Garton
Various functions in binary_test.go were missing some t.Helper() calls, so this adds them in. Change-Id: I0e5894e3c3cf72627203694a32adca51fe1563f5 GitHub-Last-Rev: b28c9255b3b5db3cf18b5406a4e13613d10b8da5 GitHub-Pull-Request: golang/go#63897 Reviewed-on: https://go-review.googlesource.com/c/go/+/539135 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: qiu laidongfeng2 <2645477756@qq.com> Auto-Submit: Keith Randall <khr@golang.org>
2024-07-16encoding/binary: use list format in docstringsKir Kolyshkin
This looks way better than the code formatting. Similar to CL 597656. Change-Id: If404c952ece384aea096f2394bd475a601627a79 Reviewed-on: https://go-review.googlesource.com/c/go/+/597657 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-07-16encoding/json: document compact json output in Encoder.EncodeSean Liao
Using the same wording as Compact. Fixes #67943 Change-Id: I578874f3e917bba1634dd988895e622a5ac78c74 Reviewed-on: https://go-review.googlesource.com/c/go/+/597976 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-06-21encoding/json: clarify the map's key type for UnmarshalJes Cok
While here, also fix doc link for encoding.TextMarshaler. Fixes #67495 Change-Id: Ia2a674c5c35b5a849ce8f5eef3d34d165b3195b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/593335 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-05-23std: fix calls to Printf(s) with non-constant sAlan Donovan
In all cases the intent was not to interpret s as a format string. In one case (go/types), this was a latent bug in production. (These were uncovered by a new check in vet's printf analyzer.) Updates #60529 Change-Id: I3e17af7e589be9aec1580783a1b1011c52ec494b Reviewed-on: https://go-review.googlesource.com/c/go/+/587855 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Russ Cox <rsc@golang.org>
2024-05-23all: change from sort functions to slices functions where feasibleIan Lance Taylor
Doing this because the slices functions are slightly faster and slightly easier to use. It also removes one dependency layer. This CL does not change packages that are used during bootstrap, as the bootstrap compiler does not have the required slices functions. It does not change the go/scanner package because the ErrorList Len, Swap, and Less methods are part of the Go 1 API. Change-Id: If52899be791c829198e11d2408727720b91ebe8a Reviewed-on: https://go-review.googlesource.com/c/go/+/587655 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2024-05-23all: document legacy //go:linkname for modules with ≥20,000 dependentsRuss Cox
For #67401. Change-Id: Icc10ede72547d8020c0ba45e89d954822a4b2455 Reviewed-on: https://go-review.googlesource.com/c/go/+/587218 Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-22encoding/binary: adjust docs for Append, Encode and DecodeJes Cok
Updates #60023 Change-Id: Ida1cc6c4f5537402e11db6b8c411828f2bcc0a5e Reviewed-on: https://go-review.googlesource.com/c/go/+/587096 Reviewed-by: Austin Clements <austin@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-05-20encoding/binary: speed up SizeLorenz Bauer
Size() is currently not called from the fast path, since the package handles the buffer sizing for Read and Write internally. This will change when adding Append() because callers can use Size to avoid allocations when writing into bytes.Buffer via AvailableBuffer for example. Add a fast path for simple types and extend the existing struct size cache to arrays of structs. Change-Id: I3af16a2b6c9e2dbe6166a2f8c96bcd2e936719e2 Reviewed-on: https://go-review.googlesource.com/c/go/+/584358 Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Austin Clements <austin@google.com>
2024-05-20encoding/binary: add Append, Encode and DecodeLorenz Bauer
Add a function which appends the binary representation of a value to the end of a slice. This allows users to encode values with zero allocations. Also add Encode and Decode functions which mimic unicode/utf8. goos: darwin goarch: arm64 pkg: encoding/binary cpu: Apple M1 Pro │ base.txt │ append.txt │ │ sec/op │ sec/op vs base │ ReadSlice1000Int32s-10 2.690µ ± 0% 2.532µ ± 3% -5.86% (p=0.002 n=6) ReadStruct-10 205.8n ± 0% 201.4n ± 1% -2.14% (p=0.002 n=6) WriteStruct-10 159.1n ± 0% 153.5n ± 0% -3.55% (p=0.002 n=6) WriteSlice1000Structs-10 129.8µ ± 0% 124.2µ ± 0% -4.34% (p=0.002 n=6) ReadSlice1000Structs-10 161.7µ ± 0% 160.3µ ± 0% -0.89% (p=0.002 n=6) ReadInts-10 156.8n ± 0% 161.6n ± 0% +3.09% (p=0.002 n=6) WriteInts-10 134.5n ± 0% 139.5n ± 2% +3.72% (p=0.002 n=6) WriteSlice1000Int32s-10 2.691µ ± 16% 2.551µ ± 4% -5.20% (p=0.002 n=6) PutUint16-10 0.6448n ± 4% 0.6212n ± 1% ~ (p=0.093 n=6) AppendUint16-10 1.414n ± 0% 1.424n ± 1% ~ (p=0.115 n=6) PutUint32-10 0.6210n ± 0% 0.6211n ± 0% ~ (p=0.833 n=6) AppendUint32-10 1.414n ± 0% 1.426n ± 1% +0.85% (p=0.017 n=6) PutUint64-10 0.6210n ± 0% 0.6394n ± 1% +2.95% (p=0.002 n=6) AppendUint64-10 1.414n ± 0% 1.427n ± 2% ~ (p=0.052 n=6) LittleEndianPutUint16-10 0.6239n ± 0% 0.6271n ± 1% ~ (p=0.063 n=6) LittleEndianAppendUint16-10 1.421n ± 0% 1.432n ± 1% +0.81% (p=0.002 n=6) LittleEndianPutUint32-10 0.6240n ± 0% 0.6240n ± 0% ~ (p=0.766 n=6) LittleEndianAppendUint32-10 1.422n ± 1% 1.425n ± 0% ~ (p=0.673 n=6) LittleEndianPutUint64-10 0.6242n ± 0% 0.6238n ± 0% -0.08% (p=0.030 n=6) LittleEndianAppendUint64-10 1.420n ± 0% 1.449n ± 1% +2.04% (p=0.002 n=6) ReadFloats-10 39.36n ± 0% 42.54n ± 1% +8.08% (p=0.002 n=6) WriteFloats-10 33.65n ± 0% 35.27n ± 1% +4.80% (p=0.002 n=6) ReadSlice1000Float32s-10 2.656µ ± 0% 2.526µ ± 1% -4.91% (p=0.002 n=6) WriteSlice1000Float32s-10 2.765µ ± 0% 2.857µ ± 3% +3.31% (p=0.002 n=6) ReadSlice1000Uint8s-10 129.1n ± 1% 130.4n ± 1% ~ (p=0.126 n=6) WriteSlice1000Uint8s-10 144.90n ± 3% 18.67n ± 2% -87.12% (p=0.002 n=6) PutUvarint32-10 12.11n ± 0% 12.12n ± 0% ~ (p=0.675 n=6) PutUvarint64-10 30.82n ± 0% 30.79n ± 1% ~ (p=0.658 n=6) AppendStruct-10 107.8n ± 0% AppendSlice1000Structs-10 119.0µ ± 0% AppendInts-10 55.29n ± 0% AppendSlice1000Int32s-10 2.211µ ± 1% geomean 33.07n 48.18n -7.03% Fixes #60023 Change-Id: Ife3f217b11d5f3eaa5a53fe8a7e877552f751f94 Reviewed-on: https://go-review.googlesource.com/c/go/+/579157 Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Austin Clements <austin@google.com> Reviewed-by: Ingo Oeser <nightlyone@googlemail.com> Reviewed-by: Austin Clements <austin@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-16crypto/x509: add text and binary marshal methods to OIDMateusz Poliwczak
Fixes #66249 Change-Id: I5973a19a087a35ad951e8a220d3e6e4456c7577f GitHub-Last-Rev: 921ca8bd0c08687bb727dbfb0890c3355eebe95b GitHub-Pull-Request: golang/go#66599 Reviewed-on: https://go-review.googlesource.com/c/go/+/575295 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Roland Shoemaker <roland@golang.org> Auto-Submit: Roland Shoemaker <roland@golang.org>
2024-05-14encoding/base32: use correct length for unpadded buffer in ReadNiklas Ott
If unpadded content was passed, in some occassions content was omitted, because the division result was floored. Ceiling it makes sure all content is always read. Fixes #65166 Change-Id: I1d8ee7ef436080483ed8f0e615b70a1013455f92 Reviewed-on: https://go-review.googlesource.com/c/go/+/581415 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-13encoding/csv: clarify that Writer uses different line break than RFC 4180 by ↵nobishino
default Package documentation of encoding/csv says: > this package supports the format described in RFC 4180. According to section 2 of RFC 4180: > Each record is located on a separate line, delimited by a line break (CRLF). On the other hand, Writer uses LF (not CRLF) as newline character by default. > If [Writer.UseCRLF] is true, the Writer ends each output line with \r\n instead of \n. Strictly speaking, this behavior is different from RFC 4180. Package documentation would improve if we clarify that point. Change-Id: I120e9332b593e1ac9ed8e49f6f8419ea88efc57d GitHub-Last-Rev: 489167eb04331fa5c623f3da9041a9d34aa258ae GitHub-Pull-Request: golang/go#67290 Reviewed-on: https://go-review.googlesource.com/c/go/+/584835 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-05-13encoding/binary: simplify encoder.valueLorenz Bauer
Remove some duplicate type switching from encoder.value. reflect.Uint and reflect.Int don't have a case statement anymore, but since they aren't valid types there is no change in semantics. goos: darwin goarch: arm64 pkg: encoding/binary cpu: Apple M1 Pro │ base.txt │ simplify.txt │ │ sec/op │ sec/op vs base │ ReadSlice1000Int32s-10 2.649µ ± 1% 2.645µ ± 0% ~ (p=0.069 n=6) ReadStruct-10 204.8n ± 2% 199.9n ± 0% -2.39% (p=0.002 n=6) WriteStruct-10 185.6n ± 2% 154.0n ± 0% -17.03% (p=0.002 n=6) WriteSlice1000Structs-10 157.9µ ± 1% 125.0µ ± 0% -20.86% (p=0.002 n=6) ReadSlice1000Structs-10 162.6µ ± 2% 159.3µ ± 0% ~ (p=0.065 n=6) ReadInts-10 159.7n ± 1% 156.7n ± 0% -1.88% (p=0.002 n=6) WriteInts-10 134.2n ± 0% 134.1n ± 0% -0.11% (p=0.011 n=6) WriteSlice1000Int32s-10 2.680µ ± 0% 2.680µ ± 0% ~ (p=0.955 n=6) PutUint16-10 0.6253n ± 2% 0.6211n ± 0% -0.67% (p=0.013 n=6) AppendUint16-10 1.417n ± 2% 1.413n ± 0% ~ (p=0.065 n=6) PutUint32-10 0.6210n ± 0% 0.6210n ± 0% ~ (p=0.835 n=6) AppendUint32-10 1.414n ± 0% 1.414n ± 0% ~ (p=1.000 n=6) PutUint64-10 0.6210n ± 0% 0.6212n ± 0% ~ (p=0.260 n=6) AppendUint64-10 1.414n ± 1% 1.417n ± 0% ~ (p=0.097 n=6) LittleEndianPutUint16-10 0.6236n ± 0% 0.6238n ± 0% ~ (p=0.426 n=6) LittleEndianAppendUint16-10 1.419n ± 0% 1.421n ± 1% ~ (p=0.054 n=6) LittleEndianPutUint32-10 0.6236n ± 0% 0.6239n ± 0% ~ (p=0.457 n=6) LittleEndianAppendUint32-10 1.421n ± 3% 1.421n ± 0% ~ (p=1.000 n=6) LittleEndianPutUint64-10 0.6242n ± 1% 0.6239n ± 0% ~ (p=0.372 n=6) LittleEndianAppendUint64-10 1.421n ± 0% 1.421n ± 0% ~ (p=1.000 n=6) ReadFloats-10 39.39n ± 0% 39.35n ± 0% -0.10% (p=0.026 n=6) WriteFloats-10 33.64n ± 0% 33.65n ± 0% ~ (p=0.297 n=6) ReadSlice1000Float32s-10 2.661µ ± 0% 2.664µ ± 0% ~ (p=0.916 n=6) WriteSlice1000Float32s-10 2.763µ ± 0% 2.758µ ± 2% ~ (p=0.225 n=6) ReadSlice1000Uint8s-10 129.5n ± 2% 129.5n ± 2% ~ (p=0.485 n=6) WriteSlice1000Uint8s-10 144.4n ± 4% 146.1n ± 2% ~ (p=0.065 n=6) PutUvarint32-10 12.12n ± 0% 12.12n ± 2% ~ (p=0.933 n=6) PutUvarint64-10 30.75n ± 0% 31.29n ± 1% +1.76% (p=0.002 n=6) geomean 33.44n 32.89n -1.65% Change-Id: Ibce978012c268a7f26fe7567c340c861fa4b115d Reviewed-on: https://go-review.googlesource.com/c/go/+/579156 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-08encoding/hex: don't overallocate memory in DecodeStringMateusz Poliwczak
Now as []byte(string) doesn't always cause heap allocation (CL 520599, #2205) we can make DecodeString simpler and more performant, by not allocating x2 the required memory. goos: linux goarch: amd64 pkg: encoding/hex cpu: AMD Ryzen 5 4600G with Radeon Graphics │ beforehex │ afterhex │ │ sec/op │ sec/op vs base │ DecodeString/256-12 197.9n ± 1% 172.2n ± 1% -13.01% (p=0.000 n=10) DecodeString/1024-12 684.9n ± 1% 598.5n ± 1% -12.61% (p=0.000 n=10) DecodeString/4096-12 2.764µ ± 0% 2.343µ ± 1% -15.23% (p=0.000 n=10) DecodeString/16384-12 10.774µ ± 1% 9.348µ ± 1% -13.23% (p=0.000 n=10) geomean 1.417µ 1.226µ -13.53% │ beforehex │ afterhex │ │ B/s │ B/s vs base │ DecodeString/256-12 1.205Gi ± 1% 1.385Gi ± 1% +14.94% (p=0.000 n=10) DecodeString/1024-12 1.393Gi ± 1% 1.593Gi ± 1% +14.42% (p=0.000 n=10) DecodeString/4096-12 1.380Gi ± 0% 1.628Gi ± 1% +17.97% (p=0.000 n=10) DecodeString/16384-12 1.416Gi ± 1% 1.632Gi ± 1% +15.25% (p=0.000 n=10) geomean 1.346Gi 1.556Gi +15.64% │ beforehex │ afterhex │ │ B/op │ B/op vs base │ DecodeString/256-12 256.0 ± 0% 128.0 ± 0% -50.00% (p=0.000 n=10) DecodeString/1024-12 1024.0 ± 0% 512.0 ± 0% -50.00% (p=0.000 n=10) DecodeString/4096-12 4.000Ki ± 0% 2.000Ki ± 0% -50.00% (p=0.000 n=10) DecodeString/16384-12 16.000Ki ± 0% 8.000Ki ± 0% -50.00% (p=0.000 n=10) geomean 2.000Ki 1.000Ki -50.00% │ beforehex │ afterhex │ │ allocs/op │ allocs/op vs base │ DecodeString/256-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ DecodeString/1024-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ DecodeString/4096-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ DecodeString/16384-12 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹ geomean 1.000 1.000 +0.00% Change-Id: I5676e48f222d90786ea18e808cb4ecde9de82597 GitHub-Last-Rev: aeedf3f6c4a2505ae9cc0ae58a94c6b2f30806fd GitHub-Pull-Request: golang/go#67259 Reviewed-on: https://go-review.googlesource.com/c/go/+/584118 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-29encoding/json: optimize field sorting with slices and cmpaimuz
Refactor field sorting in typeFields to use slices.SortFunc and cmp.Compare, resulting in performance improvements in cache misses and slight increases in hit latency. Memory allocation and operation counts also reduced significantly for cache misses. goos: darwin goarch: arm64 pkg: encoding/json cpu: Apple M2 Max │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ TypeFieldsCache/MissTypes1-12 5.068µ ± 2% 5.032µ ± 1% ~ (p=0.055 n=10) TypeFieldsCache/MissTypes10-12 15.22µ ± 2% 14.79µ ± 2% -2.84% (p=0.000 n=10) TypeFieldsCache/MissTypes100-12 98.40µ ± 3% 94.72µ ± 1% -3.73% (p=0.002 n=10) TypeFieldsCache/MissTypes1000-12 860.3µ ± 3% 840.7µ ± 1% ~ (p=0.105 n=10) TypeFieldsCache/MissTypes10000-12 8.092m ± 3% 7.987m ± 4% ~ (p=0.280 n=10) TypeFieldsCache/MissTypes100000-12 80.90m ± 9% 80.62m ± 2% ~ (p=0.631 n=10) TypeFieldsCache/MissTypes1000000-12 1009.5m ± 7% 933.8m ± 7% -7.50% (p=0.011 n=10) TypeFieldsCache/HitTypes1-12 1.554n ± 3% 1.617n ± 3% +4.05% (p=0.004 n=10) TypeFieldsCache/HitTypes10-12 1.575n ± 1% 1.624n ± 6% +3.14% (p=0.000 n=10) TypeFieldsCache/HitTypes100-12 1.566n ± 1% 1.627n ± 5% +3.86% (p=0.000 n=10) TypeFieldsCache/HitTypes1000-12 1.526n ± 4% 1.596n ± 3% +4.55% (p=0.001 n=10) TypeFieldsCache/HitTypes10000-12 1.506n ± 0% 1.573n ± 3% +4.41% (p=0.000 n=10) TypeFieldsCache/HitTypes100000-12 1.480n ± 1% 1.529n ± 7% +3.35% (p=0.001 n=10) TypeFieldsCache/HitTypes1000000-12 1.473n ± 2% 1.468n ± 2% ~ (p=0.739 n=10) geomean 1.371µ 1.374µ +0.25% │ old.txt │ new.txt │ │ B/op │ B/op vs base │ TypeFieldsCache/MissTypes1-12 2.023Ki ± 0% 2.000Ki ± 0% -1.16% (p=0.000 n=10) TypeFieldsCache/MissTypes10-12 10.95Ki ± 0% 10.71Ki ± 0% -2.17% (p=0.000 n=10) TypeFieldsCache/MissTypes100-12 101.91Ki ± 0% 99.53Ki ± 0% -2.34% (p=0.000 n=10) TypeFieldsCache/MissTypes1000-12 1044.3Ki ± 0% 1020.8Ki ± 0% -2.25% (p=0.000 n=10) TypeFieldsCache/MissTypes10000-12 9.957Mi ± 0% 9.730Mi ± 0% -2.29% (p=0.000 n=10) TypeFieldsCache/MissTypes100000-12 97.79Mi ± 0% 95.50Mi ± 0% -2.34% (p=0.000 n=10) TypeFieldsCache/MissTypes1000000-12 1018.4Mi ± 0% 995.5Mi ± 0% -2.25% (p=0.000 n=10) TypeFieldsCache/HitTypes1-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ TypeFieldsCache/HitTypes10-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ TypeFieldsCache/HitTypes100-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ TypeFieldsCache/HitTypes1000-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ TypeFieldsCache/HitTypes10000-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ TypeFieldsCache/HitTypes100000-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ TypeFieldsCache/HitTypes1000000-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ geomean ² -1.06% ² ¹ all samples are equal ² summaries must be >0 to compute geomean │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ TypeFieldsCache/MissTypes1-12 46.00 ± 0% 45.00 ± 0% -2.17% (p=0.000 n=10) TypeFieldsCache/MissTypes10-12 215.0 ± 0% 205.0 ± 0% -4.65% (p=0.000 n=10) TypeFieldsCache/MissTypes100-12 1.845k ± 0% 1.745k ± 0% -5.42% (p=0.000 n=10) TypeFieldsCache/MissTypes1000-12 18.08k ± 0% 17.08k ± 0% -5.53% (p=0.000 n=10) TypeFieldsCache/MissTypes10000-12 180.3k ± 0% 170.3k ± 0% -5.55% (p=0.000 n=10) TypeFieldsCache/MissTypes100000-12 1.804M ± 0% 1.704M ± 0% -5.54% (p=0.000 n=10) TypeFieldsCache/MissTypes1000000-12 18.04M ± 0% 17.04M ± 0% -5.54% (p=0.000 n=10) TypeFieldsCache/HitTypes1-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ TypeFieldsCache/HitTypes10-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ TypeFieldsCache/HitTypes100-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ TypeFieldsCache/HitTypes1000-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ TypeFieldsCache/HitTypes10000-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ TypeFieldsCache/HitTypes100000-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ TypeFieldsCache/HitTypes1000000-12 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹ geomean ² -2.49% ² ¹ all samples are equal ² summaries must be >0 to compute geomean Change-Id: I62b8f524f5747f4f1b9241a1d849efeef1851049 GitHub-Last-Rev: d16772d4fb44f76e2688e15f1bdfc7db14bb55c6 GitHub-Pull-Request: golang/go#67046 Reviewed-on: https://go-review.googlesource.com/c/go/+/581895 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Joedian Reid <joedian@google.com>
2024-04-11all: consistently use "IEEE 754" over "IEEE-754"Joe Tsai
There is no hyphen between the organization and the number. For example, https://standards.ieee.org/ieee/754/6210/ shows the string "IEEE 754-2019" and not "IEEE-754-2019". This assists in searching for "IEEE 754" in documentation and not missing those using "IEEE-754". Change-Id: I9a50ede807984ff1e2f17390bc1039f6a5d162e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/575438 Run-TryBot: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Joseph Tsai <joetsai@digital-static.net> TryBot-Result: Gopher Robot <gobot@golang.org> TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-11encoding/json: use slices to simplify the codeapocelipes
Use "slices.Equal" instead of "reflect.DeepEqual". Replace unnecessary helper type "byIndex" with "slices.SortFunc". No effect on benchmarks. Change-Id: I1fb2768ea6d9db7f487408fa109343be3f1741d5 GitHub-Last-Rev: 8429bc145272ae620fcd001b1de393bf3c0b6108 GitHub-Pull-Request: golang/go#66646 Reviewed-on: https://go-review.googlesource.com/c/go/+/575715 Reviewed-by: qiu laidongfeng2 <2645477756@qq.com> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-05encoding/csv: port the go-fuzz function to native fuzzingDaniel Martí
Beyond the required file move and refactor to use the testing package, a number of changes were made to get the fuzzing working properly. First, add more logs to see what is going on. Second, some option combinations set Comma to the null character, which simply never worked at all. I suspect the author meant to leave the comma character as the default instead. This was spotted thanks to the added logging. Third, the round-trip DeepEqual check did not work at all when any comments were involved, as the writer does not support them. Fourth and last, massage the first and second parsed records before comparing them with DeepEqual, as the nature of Reader and Writer causes empty quoted records and CRLF sequences to change. With all the changes above, the fuzzing function appears to work normally on my laptop now. I fuzzed for a solid five minutes and could no longer encounter any errors or panics. Change-Id: Ie27f65f66099bdaa076343cee18b480803d2e4d3 Reviewed-on: https://go-review.googlesource.com/c/go/+/576375 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-02encoding/json: prevent duplicate slicebytetostringShengyu Zhang
When storing literal to JSON number v, if s is valid number, the slicebytetostring operation will be performed twice. In fact, the operation is unavoidable on any code path, so just perform it at the very beginning. This is not a big optimization, but better than nothing: $ ../bin/go test ./encoding/json/ -bench UnmarshalNumber -run NOTEST -benchtime 10000000x -count 16 > old.txt $ ../bin/go test ./encoding/json/ -bench UnmarshalNumber -run NOTEST -benchtime 10000000x -count 16 > new.txt $ benchstat old.txt new.txt │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ UnmarshalNumber-8 234.5n ± 3% 228.2n ± 4% -2.67% (p=0.033 n=16) │ old.txt │ new.txt │ │ B/op │ B/op vs base │ UnmarshalNumber-8 168.0 ± 0% 168.0 ± 0% ~ (p=1.000 n=16) ¹ ¹ all samples are equal │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ UnmarshalNumber-8 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=16) ¹ ¹ all samples are equal Change-Id: I1dfdb1ed0883e385f753b2046b7f047c792aa4e3 GitHub-Last-Rev: d236dd7265f110dbb6e0b9b0a824aab9ba7c36be GitHub-Pull-Request: golang/go#61242 Reviewed-on: https://go-review.googlesource.com/c/go/+/508556 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-03-28encoding/asn1: simplify appendFourDigitsapocelipes
The new code does not need a for-loop and is easier to read. Change-Id: Ic182d63c4779c2179b721fcfaec362681284cc16 GitHub-Last-Rev: b3ee265df7eb4d51c945bf5453eb1b09f91912d9 GitHub-Pull-Request: golang/go#63879 Reviewed-on: https://go-review.googlesource.com/c/go/+/538721 Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2024-03-26all: fix a large number of commentscui fliter
Partial typo corrections, following https://go.dev/wiki/Spelling Change-Id: I2357906ff2ea04305c6357418e4e9556e20375d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/573776 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-03-22encoding/gob: close files used in dump.go and encgen.goguoguangwu
Change-Id: Ic1dd899fa52fdf9098955fc14a828d2f07da8037 GitHub-Last-Rev: 6e0438ec7178382e2a7d56f0a053cec33fbe9e78 GitHub-Pull-Request: golang/go#66437 Reviewed-on: https://go-review.googlesource.com/c/go/+/573235 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Rob Pike <r@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Rob Pike <r@golang.org>
2024-03-20encoding/gob: close output fileguoguangwu
Change-Id: Ia9ecb82e87fca319e89aa1779aeed0f573fa808f GitHub-Last-Rev: 33361bcb8ae5817dcc618d67d69009001b271ffc GitHub-Pull-Request: golang/go#66417 Reviewed-on: https://go-review.googlesource.com/c/go/+/572955 Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-14encoding/gob: make x509.Certificate marshalable againRuss Cox
The OID type is not exported data like most of the other x509 structs. Using it in x509.Certificate made Certificate not gob-compatible anymore, which breaks real-world code. As a temporary fix, make gob ignore that field, making it work as well as it did in Go 1.21. For Go 1.23, we anticipate adding a proper fix and removing the gob workaround. See #65633 and #66249 for more details. For #66249. Fixes #65633. Change-Id: Idd1431d15063b3009e15d0565cd3120b9fa13f61 Reviewed-on: https://go-review.googlesource.com/c/go/+/571095 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org>
2024-03-13encoding/binary: cache struct sizes to speed up Read and Write for slice of ↵kwakubiney
structs. A lot of allocations happen in dataSize due to reflection. Cache the result of the function when encoding a slice of structs similar to what is done for struct types so that subsequent calls to dataSize can avoid allocations. │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ WriteSlice1000Structs-2 846.7µ ± 4% 856.4µ ± 3% ~ (p=0.602 n=20) │ old.txt │ new.txt │ │ B/s │ B/s vs base │ WriteSlice1000Structs-2 84.48Mi ± 4% 83.52Mi ± 3% ~ (p=0.602 n=20) │ old.txt │ new.txt │ │ B/op │ B/op vs base │ WriteSlice1000Structs-2 80.18Ki ± 0% 80.06Ki ± 0% -0.15% (p=0.000 n=20) │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ WriteSlice1000Structs-2 16.000 ± 0% 1.000 ± 0% -93.75% (p=0.000 n=2 │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ ReadSlice1000Structs-2 847.4µ ± 4% 821.1µ ± 3% -3.10% (p=0.012 n=20) │ old.txt │ new.txt │ │ B/s │ B/s vs base │ ReadSlice1000Structs-2 84.40Mi ± 4% 87.11Mi ± 3% +3.20% (p=0.012 n=20) │ old.txt │ new.txt │ │ B/op │ B/op vs base │ ReadSlice1000Structs-2 80.12Ki ± 0% 80.00Ki ± 0% -0.15% (p=0.000 n=20) │ old.txt │ new.txt │ │ allocs/op │ allocs/op vs base │ ReadSlice1000Structs-2 16.000 ± 0% 1.000 ± 0% -93.75% (p=0.000 n=20) Fixes #66253 Change-Id: I8227e61306db1fe103489ea4fee2429247c3debc Reviewed-on: https://go-review.googlesource.com/c/go/+/570855 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-03-08Revert "encoding/xml: reject XML declaration after start of document"Russ Cox
This reverts commit 8a0fbd75a54c27ff2ae624ac2775bf752cdbceb4. Reason for revert: Breaking real-world tests inside Google, which means it probably breaks real-world tests outside Google. One instance I have seen is a <!-- --> comment (often a copyright notice) before the procinst. Another test checks that a canonicalizer can handle a test input that simply has procinsts mid-XML. XML is full of contradictions, XML implementations more so. If we are going to start being picky, that probably needs to be controlled by a GODEBUG (and a proposal). For #65691 (will reopen manually). Change-Id: Ib52d0944b1478e71744a2a35b271fdf7e1c972ca Reviewed-on: https://go-review.googlesource.com/c/go/+/570175 Reviewed-by: Than McIntosh <thanm@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Russ Cox <rsc@golang.org>
2024-03-06encoding/binary: use built-in clear to simplify codeJes Cok
Change-Id: I2f3c7f4a4848ad0fbbf79bd8919b1e2abee72f3f GitHub-Last-Rev: 06d0047b28fe1c8c87f84aca049b8c76778732b9 GitHub-Pull-Request: golang/go#66136 Reviewed-on: https://go-review.googlesource.com/c/go/+/569280 Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-02-29encoding/json: make use of reflect.Type.{OverflowInt, OverflowUint}Jes Cok
CL 567296 added {OverflowComplex, OverflowFloat, OverflowInt, OverflowUint} to reflect.Type, this CL uses these methods to simplify code. For #60427 Change-Id: I229aef9e4095a2f025afd782081f6c9e6d7710f3 GitHub-Last-Rev: c824e5a1b5547e2cc23142fbcf0d6dd59f0e8506 GitHub-Pull-Request: golang/go#66000 Reviewed-on: https://go-review.googlesource.com/c/go/+/567775 Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-28encoding/xml: display closing space in error messageConstantin Konstantinidis
Fixes #48890 Change-Id: I7644d091ad92663bda52ef4905239ec499ef9207 Reviewed-on: https://go-review.googlesource.com/c/go/+/535535 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2024-02-27encoding/xml: remove unnecessary fmt.Sprintf callguoguangwu
Change-Id: Iba6014340d8b697a3a26b35e8d5a702ccf332e10 GitHub-Last-Rev: ef60463c7b98c2bdabe6d04e0f86947b7f395765 GitHub-Pull-Request: golang/go#65872 Reviewed-on: https://go-review.googlesource.com/c/go/+/565841 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2024-02-22encoding/xml: reject XML declaration after start of documentAxel Wagner
The XML specification requires an XML declaration, if present, to only appear at the very beginning of the document, not even preceded by whitespace. The parser currently accepts it at any part of the input. Rejecting whitespace at the beginning of the file might break too many users. This change instead only rejects an XML declaration preceded by a non-whitespace token *and* allows the Encoder to emit whitespace before an XML declaration. This means that a token stream produced by the Decoder can be passed to the Encoder without error, while we still don't emit clearly invalid XML. This might break programs depending on Decoder allowing arbitrary XML before the XML declaration. Fixes #65691. Change-Id: Ib1d4b3116aee63f40fd377f90595780b4befd1ee Reviewed-on: https://go-review.googlesource.com/c/go/+/564035 Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-08encoding/xml: rewrite func procInstJes Cok
This CL tries to make function procInst more exact, also adds test cases, however, including tricky ones. Change-Id: If421299fc84d136e56a25dba7a4919c4424702c8 GitHub-Last-Rev: b9a3192718ae5535d66fddd260c27b48d93b4af1 GitHub-Pull-Request: golang/go#64336 Reviewed-on: https://go-review.googlesource.com/c/go/+/544475 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-10-18encoding/json: use reflect.Value.IsZeroandig
IsZero does the same thing, using this rather than writing it again. Follow-up to https://github.com/golang/go/pull/63519 Change-Id: I93768874052935dd7cb58804f22748091bcc3ef7 GitHub-Last-Rev: dfbc6ed635125535a73fe509716e0df31cc8f7b0 GitHub-Pull-Request: golang/go#63540 Reviewed-on: https://go-review.googlesource.com/c/go/+/535415 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-10-12encoding/xml: use reflect.Value.IsZeroapocelipes
IsZero does the same thing, using this rather than writing it again. Change-Id: I62810ac2d1a6e189feac03b022c8931fb6993e19 GitHub-Last-Rev: 1d5fd10d96baf75e8b170a2c71949ff3d0884c46 GitHub-Pull-Request: golang/go#63519 Reviewed-on: https://go-review.googlesource.com/c/go/+/534935 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-10-06encoding/json: fix appendCompact escapingAlexander Yastrebov
CL 469555 changed Compact to use append instead of bytes.Buffer. appendCompact iterates over input src slice and performs escaping of certain characters. To optimize copying it does not copy characters one by one but keeps track of the start offset of the data to copy when it reaches next character to escape or the end of the input. This start offset may become greater than input character offset so copying of preceding data should check this condition. CL 469555 removed boundary checks for copying data preceding escaped characters and this change restores them. Fixes https://github.com/golang/go/issues/63379 Change-Id: I5b7856239f256c67faf58834705675c0aea08cc2 GitHub-Last-Rev: 661576fb54951a05a8399beb3f9ac2a2f9a340b4 GitHub-Pull-Request: golang/go#63400 Reviewed-on: https://go-review.googlesource.com/c/go/+/533275 Run-TryBot: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Benny Siegert <bsiegert@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-09-27all: use the indefinite article an in commentsJes Cok
This is a follow up of CL 530120. Change-Id: Ifa0bd1c3bb9bb1202568eaae27500bcea376f56b GitHub-Last-Rev: b4154fa1fc205a6a1af050ab49a4738f73b3c32a GitHub-Pull-Request: golang/go#63228 Reviewed-on: https://go-review.googlesource.com/c/go/+/531136 Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-09-08encoding: modernize Go documentationJoe Tsai
Across all encoding packages, linkify declarations if possible. In some cases, we convert a code block into a bulleted list, which then further allows for more linkification. Change-Id: I68fedf362615b34228bab5d4859b7d87d831c570 Reviewed-on: https://go-review.googlesource.com/c/go/+/524977 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>