aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json
AgeCommit message (Collapse)Author
2025-06-25encoding/json/jsontext: rename Encoder.UnusedBuffer as Encoder.AvailableBufferJoe Tsai
This follows the precedent set by: bufio.Writer.AvailableBuffer bytes.Buffer.AvailableBuffer both with methods that return a zero-length buffer that is intended to only be used with a following Write call. This keeps the older UnusedBuffer method around so that at least one commit that has both methods for migration purposes. Updates #71497 Change-Id: I3815f593e09f645280ae5ad9cbdd63a6c147123b Reviewed-on: https://go-review.googlesource.com/c/go/+/683896 Reviewed-by: Damien Neil <dneil@google.com> TryBot-Bypass: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-06-24encoding/json: use zstd compressed testdataJoe Tsai
There is a non-public zstd decoder in the stdlib (CL 473356) and also zstd compressed testdata already present. Delete testdata/code.json.gz and instead use internal/jsontest/testdata/golang_source.json.zst, which has exactly the same content: $ cat internal/jsontest/testdata/golang_source.json.zst | zstd -d | sha1sum 3f70b6fd429f4aba3e8e1c3e5a294c8f2e219a6e - $ cat testdata/code.json.gz | zstd -d | sha1sum 3f70b6fd429f4aba3e8e1c3e5a294c8f2e219a6e - This will reduce the size of the final Go release by 118KB. Updates #71845 Change-Id: I6da2df27bd260befc0a44c6bc0255365be0a5b0f Reviewed-on: https://go-review.googlesource.com/c/go/+/525516 Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Bypass: Damien Neil <dneil@google.com>
2025-06-24encoding/json/v2: support ISO 8601 durationsJoe Tsai
Based on the discussion in #71631, it is hotly contested whether the default JSON representation for a Go time.Duration should be the time.Duration.String format or a particular profile of ISO 8601. Regardless of the default, it seems clear that we should at least support ISO 8601 if specified via a format flag. Note that this CL does not alter the default representation. Unfortunately, ISO 8601 is a large and evolving standard with many optional extensions and optional restrictions. Thus, the term "ISO 8601 duration" unfortunately does not resolve to a particular grammar, nor one that is stable. However, there is precedence that we can follow in this matter. JSON finds its heritage in JavaScript and JavaScript is adding a Temporal.Duration type whose default JSON representation is ISO 8601. There is a well-specified grammar for their particular profile of ISO 8601, which is documented at: https://tc39.es/proposal-temporal/#prod-Duration This particular CL adds support for ISO 8601 according to the exact same grammar that JavaScript uses. While Temporal.Duration is technically still a proposal, it is already in stage 3 of the TC39 proposal process (i.e., "no changes to the proposal are expected" and "has been recommended for implementation") and therefore close to final adoption. One major concern with ISO 8601 is that it supports nominal date units like years, months, weeks, and days that do not have an accurate meaning without being anchored to a particular point in time and place on Earth. Fortunately, JavaScript (by default) avoids producing Temporal.Duration values with nominal units unless arithmetic in JavaScript explicitly sets a largestUnits value that is larger than "hours". In the Go implementation, we support syntactically parsing the full ISO 8601 grammar (according to JavaScript), but semantically report an error if nominal units are present. This ensures that ISO 8601 durations remain accurate so long as they only use the accurate units of hours, minutes, or seconds. Updates #71631 Change-Id: I983593662f2150461ebc486a5acfeb72f0286939 Reviewed-on: https://go-review.googlesource.com/c/go/+/682403 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-06-24encoding/json/v2: reject unquoted dash as a JSON field nameJoe Tsai
In this blog: https://blog.trailofbits.com/2025/06/17/unexpected-security-footguns-in-gos-parsers/ the concern was raised that whenever "-" is combined with other options, the "-" is intepreted as as a name, rather than an ignored field, which may go contrary to user expectation. Static analysis demonstrates that there are ~2k instances of `json:"-,omitempty" in the wild, where almost all of them intended for the field to be ignored. To prevent this footgun, reject any tags that has "-," as a prefix and warn the user to choose one of the reasonable alternatives. The documentation of json/v2 already suggests `json:"'-'"` as the recommended way to explicitly specify dash as the name. See Example_fieldNames for example usages of the single-quoted literal. Update the v1 json documentation to suggest the same thing. Updates #71497 Change-Id: I7687b6eecdf82a5d894d057c78a4a90af4f5a6e4 Reviewed-on: https://go-review.googlesource.com/c/go/+/683175 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-06-23encoding/json/v2: report error on time.Duration without explicit formatJoe Tsai
The default representation of a time.Duration is still undecided. In order to keep the future open, report an error on a time.Duration without an explicit format flag provided. Updates #71631 Change-Id: I08248404ff6551723851417c8188a13f53c61937 Reviewed-on: https://go-review.googlesource.com/c/go/+/682455 Auto-Submit: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
2025-06-23encoding/json/jsontext: consistently use JSON terminologyJoe Tsai
RFC 8259, section 2 uses the term "begin-array" amd "begin-object" rather than "start array" or "start object". Be consistent in our documentation. Change-Id: I172eb354c5e64b84c74bd662b1e581424e719a32 Reviewed-on: https://go-review.googlesource.com/c/go/+/683155 Auto-Submit: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
2025-06-17encoding/json/jsontext: fix spelling errorKevin Burke
Change-Id: Ic1f385afbe35addba8b3c439ccb64c56b1d300c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/681795 Reviewed-by: Sean Liao <sean@liao.dev> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-06-11encoding/json/jsontext, encoding/json/v2: document experimental natureDamien Neil
Change-Id: I7b2c391749e0113e006f37b2ac1ebfe3ee0a4e0e Reviewed-on: https://go-review.googlesource.com/c/go/+/680715 TryBot-Bypass: Damien Neil <dneil@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Auto-Submit: Damien Neil <dneil@google.com>
2025-05-20encoding/json: avoid supurious synctest deadlock detectionDamien Neil
Use a sync.OnceValue rather than a sync.WaitGroup to coordinate access to encoderCache entries. The OnceValue better expresses the intent of the code (we want to initialize the cache entry only once). However, the motivation for this change is to avoid testing/synctest incorrectly reporting a deadlock when multiple bubbles call Marshal at the same time. Goroutines blocked on WaitGroup.Wait are "durably blocked", causing confusion when a goroutine in one bubble Waits for a goroutine in a different bubble. Goroutines blocked on OnceValue are not durably blocked, avoiding the problem. Fixes #73733 For #67434 Change-Id: I81cddda80af67cf5c280fd4327620bc37e7a6fe6 Reviewed-on: https://go-review.googlesource.com/c/go/+/673335 Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-04-18encoding/json: add json/v2 with GOEXPERIMENT=jsonv2 guardDamien Neil
This imports the proposed new v2 JSON API implemented in github.com/go-json-experiment/json as of commit d3c622f1b874954c355e60c8e6b6baa5f60d2fed. When GOEXPERIMENT=jsonv2 is set, the encoding/json/v2 and encoding/jsontext packages are visible, the encoding/json package is implemented in terms of encoding/json/v2, and the encoding/json package include various additional APIs. (See #71497 for details.) When GOEXPERIMENT=jsonv2 is not set, the new API is not present and the encoding/json package is unchanged. The experimental API is not bound by the Go compatibility promise and is expected to evolve as updates are made to the json/v2 proposal. The contents of encoding/json/internal/jsontest/testdata are compressed with zstd v1.5.7 with the -19 option. Fixes #71845 For #71497 Change-Id: Ib8c94e5f0586b6aaa22833190b41cf6ef59f4f01 Reviewed-on: https://go-review.googlesource.com/c/go/+/665796 Auto-Submit: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-04-15encoding/json: correct method comment to reflect actual argumentAlex S
Change-Id: I0e9040ee5b84463f0391e8e4ae1b64a036867913 GitHub-Last-Rev: 859c82a254f49fa4b5376c0e8fff6f62f5131f62 GitHub-Pull-Request: golang/go#73123 Reviewed-on: https://go-review.googlesource.com/c/go/+/662015 Auto-Submit: Sean Liao <sean@liao.dev> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Sean Liao <sean@liao.dev>
2025-02-25encoding/json: use builtin min function in appendStringJes Cok
To make code a bit simpler. Change-Id: I59fca1d5760e304abd53873ecf9ca8b2903e02e8 GitHub-Last-Rev: 1369df6da16121c342a4e678efe3e5b082485b74 GitHub-Pull-Request: golang/go#71873 Reviewed-on: https://go-review.googlesource.com/c/go/+/651355 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: Michael Pratt <mpratt@google.com>
2025-01-14encoding/json: cleanup testsJoe Tsai
Perform minor cleanups in tests to improve printout of diffs and/or follow modern coding style. This reduces the amount of diffs between v1 and the v2 prototype. Change-Id: I019bb9642e2135f2fa3eac6abfa6df91c397aa82 Reviewed-on: https://go-review.googlesource.com/c/go/+/642257 Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Joseph Tsai <joetsai@digital-static.net> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-01-13encoding/json: add cases to TestUnmarshal for fatal syntactic errorsJoe Tsai
The presence of a syntax error in the input immediately unmarshaling before unmarshaling into the underlying value. Otherwise, semantic errors are generally lazily reported and allow unmarshaling to continue on. Change-Id: Icf1cfc684e415312d9c8bf739c396ede15299d7d Reviewed-on: https://go-review.googlesource.com/c/go/+/642295 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-01-13encoding/json: always check resulting Go value for unmarshalingJoe Tsai
Even if an error occurs during unmarshal, check the resulting Go value. The documented API specifies no guarantees on how much of a Go value will be populated when an error occurs and the "json" package is technically not bounded by the Go compatibility agreement to ensure this behavior never changes. However, there is still value in running checks for what exactly what is partially mutated in the event of an error even if this is not guaranteed behavior. Change-Id: I6e923a31f77768a14c4adfb0d37dbeee5807a4a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/642275 Auto-Submit: Joseph Tsai <joetsai@digital-static.net> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-01-08encoding/json: improve fidelity of TestUnmarshal for NumbersJoe Tsai
In particular, cover the behavior of unmarshaling a JSON string into a Number type regardless of whether the `string` option is specified or not. Change-Id: Ibc55f16860442240bcfeea1fd51aaa76f7e50f67 Reviewed-on: https://go-review.googlesource.com/c/go/+/641416 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-12-30encoding/json: remove suggestion on Unmarshaler with JSON nullJoe Tsai
It is not true that Unmarshal always treats a JSON null as being equivalent to a no-op. For bools, ints, uints, floats, strings, arrays, and structs, it treats a JSON null as a no-op. However, for []byte, slice, map, pointer, or interface, it zeros the underlying value. Remove this suggestion as the actual behavior is inconsistent. Note that the proposed behavior in v2 Unmarshal is to consistently zero out the underlying value. Change-Id: I02cef0bf7919f25cfd0aceb04486d37498761181 Reviewed-on: https://go-review.googlesource.com/c/go/+/638416 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
2024-12-27encoding/json: expand and modernize TestInterfaceSetJoe Tsai
Add more test cases to cover a wider range of edge cases. Use a generic addr function to take the address of a value. Even though redudant, explicitly include a cast to the top-level Go type so that it is more readable what the expected input and ouput types are. Change-Id: I3ef68df6f1beb903ae237cd49f3dcb91e5270fe7 Reviewed-on: https://go-review.googlesource.com/c/go/+/638256 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-19encoding/json: check exact structure of local error types in testsJoe Tsai
During the development of error wrapping (#29934), the tests were modified to stop using reflect.DeepEqual since the prototype for error wrapping at the time included frame information of where the error was created. However, that change diminished the fidelity of the test so that it is no longer as strict, which affects the endeavor to implement v1 in terms of the v2 prototype. For locally declared error types, use reflect.DeepEqual to check that the exact structure of the error value matches. Change-Id: I443d418533866ab8d533bca3785fdc741e2c140e Reviewed-on: https://go-review.googlesource.com/c/go/+/629517 Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-11-08encoding/json, text/template: use reflect.Value.Equal instead of ==Emmanuel T Odeke
This change applies a fix for a reflect.Value incorrect comparison using "==" or reflect.DeepEqual. This change is a precursor to the change that'll bring in the static analyzer "reflectvaluecompare", by ensuring that all tests pass beforehand. Updates #43993 Change-Id: I6c47eb0a1de6353ac7495cb8cb49b318b7ebba56 Reviewed-on: https://go-review.googlesource.com/c/go/+/626116 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> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2024-10-23encoding/json: clarify omitempty option for {array,slice,map,string}Jes Cok
This CL is inspired by: https://github.com/golang/go/issues/29310#issuecomment-758768325 When I read omitempty option in encoding/xml package, I find it's a bit different than encoding/json package. I think it's more precise to say: "any array, slice, map, or string of length zero." Update #29310 Change-Id: Ia77167c3155411640224b349d4b34d0bb91ee11e GitHub-Last-Rev: a4cf00dcc75067bd259bc600f288c9de4b5393cf GitHub-Pull-Request: golang/go#69984 Reviewed-on: https://go-review.googlesource.com/c/go/+/621835 Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Michael Pratt <mpratt@google.com>
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-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-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-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-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: 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-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-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-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-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>
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-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-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>
2023-08-29encoding/json: adjust comment about encoding \b and \fChristian Höppner
The encoding for the control characters \b and \f was changed in http://go.dev/cl/521675. This CL adjusts the corresponding comment about encoding bytes < 0x20. Change-Id: I83b7311e4fa0731f6601ca64a66042425b4cecac Reviewed-on: https://go-review.googlesource.com/c/go/+/523435 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Joseph Tsai <joetsai@digital-static.net> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
2023-08-25encoding/json: modernize testsJoe Tsai
There are no changes to what is being tested. No test cases were removed or added. Changes made: * Use a local implementation of test case position marking. See #52751. * Use consistent names for all test tables and variables. * Generally speaking, follow modern Go style guide for tests. * Move global tables local to the test function if possible. * Make every table entry run in a distinct testing.T.Run. The purpose of this change is to make it easier to perform v1-to-v2 development where we want v2 to support close to bug-for-bug compatibility when running in v1 mode. Annotating each test case with the location of the test data makes it easier to jump directly to the test data itself and understand why this particular case is failing. Having every test case run in its own t.Run makes it easier to isolate a particular failing test and work on fixing the code until that test case starts to pass again. Unfortunately, many tests are annotated with an empty name. An empty name is better than nothing, since the testing framework auto assigns a numeric ID for duplicate names. It is not worth the trouble to give descriptive names to each of the thousands of test cases. Change-Id: I43905f35249b3d77dfca234b9c7808d40e225de8 Reviewed-on: https://go-review.googlesource.com/c/go/+/522880 Auto-Submit: Joseph Tsai <joetsai@digital-static.net> Run-TryBot: Joseph Tsai <joetsai@digital-static.net> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2023-08-25encoding/json: avoid allocation when decoding number typeskorzhao
In CL 345488, we optimized strconv.ParseXXX for []byte arguments. That allows immediate casting of a []byte to a string that does not escape to be copied on the stack. Performance: goos: darwin goarch: arm64 pkg: encoding/json old sec/op new sec/op delta CodeUnmarshal-10 3.019m ± 6% 2.865m ± 10% -5.10% (p=0.043 n=10) CodeUnmarshalReuse-10 2.528m ± 4% 2.274m ± 13% -10.03% (p=0.009 n=10) geomean 2.762m 2.553m -7.60% old B/s new B/s delta CodeUnmarshal-10 613.1Mi ± 5% 646.0Mi ± 9% +5.37% (p=0.043 n=10) CodeUnmarshalReuse-10 732.1Mi ± 4% 813.7Mi ± 12% +11.15% (p=0.009 n=10) geomean 669.9Mi 725.0Mi +8.22% old B/op new B/op delta CodeUnmarshal-10 2.782Mi ± 0% 1.918Mi ± 0% -31.04% (p=0.000 n=10) CodeUnmarshalReuse-10 1600.8Ki ± 0% 713.3Ki ± 0% -55.44% (p=0.000 n=10) geomean 2.085Mi 1.156Mi -44.57% old allocs/op new allocs/op delta CodeUnmarshal-10 91.31k ± 0% 39.99k ± 0% -56.20% (p=0.000 n=10) CodeUnmarshalReuse-10 76.58k ± 0% 25.23k ± 0% -67.06% (p=0.000 n=10) geomean 83.62k 31.76k -62.02% Change-Id: I208c57089040daee0f9d979d1df725e3acf34f81 Reviewed-on: https://go-review.googlesource.com/c/go/+/518277 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Run-TryBot: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2023-08-25encoding/json: optimize Marshal for mapskorzhao
Optimize marshaling of maps by using slices.SortFunc. This drops an unnecessary field from reflectWithString, which also reduces the cost of each swap operation. benchmark old ns/op new ns/op delta BenchmarkMarshalMap-10 228 139 -39.24% benchmark old allocs new allocs delta BenchmarkMarshalMap-10 11 8 -27.27% benchmark old bytes new bytes delta BenchmarkMarshalMap-10 432 232 -46.30% Change-Id: Ic2ba7a1590863c7536305c6f6536372b26ec9b0c Reviewed-on: https://go-review.googlesource.com/c/go/+/515176 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: qiulaidongfeng <2645477756@qq.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-08-23encoding/json: encode \b and \f as '\b' and '\f' in JSON stringsJoe Tsai
According to RFC 8259, there are exactly 5 control characters that have a shorter escape sequence than the generic \uXXXX format. Over the years, we added ad-hoc support for the short sequences: * https://go.dev/cl/4678046 supports \r and \n * https://go.dev/cl/162340043 supports \t This CL completes the set by supporting \b and \f. This may change the encoding of strings in relatively rare cases, but is a permissible change since the Go 1 compatibility document does not guarantee that "json" produces byte-for-byte identical outputs. In fact, we have made even more observable output changes in the past such as with https://go.dev/cl/30371 which changes the representation of many JSON numbers. This change is to prepare the path forward for a potential v2 "json" package, which has more consistent encoding of JSON strings. Change-Id: I11102a0602dfb1a0c14eaad82ed23e8df7553c6b Reviewed-on: https://go-review.googlesource.com/c/go/+/521675 Auto-Submit: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-08-18encoding/json: use base64.Encoding.AppendEncodeAndy Pan
For #53693 Change-Id: I6a428a4a10a2e2efa03296f539e190f0743c1f46 Reviewed-on: https://go-review.googlesource.com/c/go/+/520755 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Andy Pan <panjf2000@gmail.com>
2023-08-14encoding/json: declare hex as a constJes Cok
hex is in fact immutable, declare it as a const to avoid accidental modification, also for consistency with other packages. Change-Id: I99f292e98c82d4c4526e46c9897d154d0c073da5 GitHub-Last-Rev: d2f06965e7e03df470d8c3c8882619187abf1609 GitHub-Pull-Request: golang/go#62011 Reviewed-on: https://go-review.googlesource.com/c/go/+/519155 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.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-08-07all: add a few more godoc linksDaniel Martí
Over the past few months as I read the standard library's documentation I kept finding spots where godoc links would have helped me. I kept adding to a stash of changes to fix them up bit by bit. The stash has grown big enough by now, and we're nearing a release, so I think it's time to merge to avoid git conflicts or bit rot. Note that a few sentences are slightly reworded, since "implements the Fooer interface" can just be "implements [Fooer]" now that the link provides all the context needed to the user. Change-Id: I01c31d3d3ff066d06aeb44f545f8dd0fb9a8d998 Reviewed-on: https://go-review.googlesource.com/c/go/+/508395 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-08-02encoding/json: adjust comment to keep the same style as comment aboveJes Cok
Change-Id: Id47d32d18031883b874bba4cf8541f75c5d7f9db GitHub-Last-Rev: 98c671c00c112e7bdf70b2f901a4f7682f922725 GitHub-Pull-Request: golang/go#61711 Reviewed-on: https://go-review.googlesource.com/c/go/+/515215 Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: David Chase <drchase@google.com>
2023-08-01encoding/json: replace "between or" with "between and" in commentJes Cok
Change-Id: Id19a15f9367de10e08a9ec22a8cb50c58d517906 GitHub-Last-Rev: f413d71c9ad0f2efc0b4811c7188cc2caa9c1de0 GitHub-Pull-Request: golang/go#61701 Reviewed-on: https://go-review.googlesource.com/c/go/+/514976 Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-08-01encoding/json: use reflect.TypeFor for known typesIan Lance Taylor
For #60088 Change-Id: I2e471c76de62944b14472966b63f5778124b9b8b Reviewed-on: https://go-review.googlesource.com/c/go/+/514655 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Run-TryBot: Joseph Tsai <joetsai@digital-static.net> 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: David Chase <drchase@google.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2023-07-31encoding/json: optimize Unmarshal for mapskorzhao
benchmark old ns/op new ns/op delta BenchmarkUnmarshalMap-10 218 172 -21.28% benchmark old allocs new allocs delta BenchmarkUnmarshalMap-10 15 12 -20.00% benchmark old bytes new bytes delta BenchmarkUnmarshalMap-10 328 256 -21.95% Change-Id: Ie20ab62731c752eb0040c6d1591fedd7d12b1e0c Reviewed-on: https://go-review.googlesource.com/c/go/+/514100 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-07-29encoding/json: replace dead link in appendStringkorzhao
Change-Id: I534698008b46b23352d9f1fed891fd96dc0947b7 Reviewed-on: https://go-review.googlesource.com/c/go/+/507115 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>