<feed xmlns='http://www.w3.org/2005/Atom'>
<title>go/src/encoding/json/decode_test.go, branch fix-runtime-test-GOMAXPROCS</title>
<subtitle>Fork of Go programming language with my patches.</subtitle>
<id>http://git.kilabit.info/go/atom?h=fix-runtime-test-GOMAXPROCS</id>
<link rel='self' href='http://git.kilabit.info/go/atom?h=fix-runtime-test-GOMAXPROCS'/>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/'/>
<updated>2025-07-11T21:27:16Z</updated>
<entry>
<title>encoding/json/v2: report wrapped io.ErrUnexpectedEOF</title>
<updated>2025-07-11T21:27:16Z</updated>
<author>
<name>Joe Tsai</name>
<email>joetsai@digital-static.net</email>
</author>
<published>2025-07-09T23:55:14Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=a0a99cb22b2045b15509d1002a655db407a44a50'/>
<id>urn:sha1:a0a99cb22b2045b15509d1002a655db407a44a50</id>
<content type='text'>
In the event that the input is just JSON whitespace,
the underlying jsontext.Decoder treats this as an empty stream
and reports io.EOF.

The logic in unmarshalFull simply casted io.EOF as io.ErrUnexpectedEOF,
which is inconsistent with how all other io.ErrUnexpectedEOF are reported,
which are wrapped within a jsontext.SyntacticError.
Do the same thing for consistency.

We add a v1 test (without goexperiment.jsonv2) to verify that
the behavior is identical to how v1 has always behaved.

We add a v1in2 test (with goexperiment.jsonv2) to verify that
the v1in2 behavior correctly replicates historical v1 behavior.

We also fix a faulty check in v1 Decoder.Decode,
where it tried to detect errUnexpectedEnd and
return an unwrapped io.ErrUnexpectedEOF error.
This is the exact semantic that v1 has always done
in streaming Decoder.Decode (but not non-streaming Unmarshal).
There is a prior bug reported in #25956 about this inconsistency,
but we aim to preserve historical v1 behavior to reduce
the probability of churn when v1 is re-implemented in terms of v2.

Fixes #74548

Change-Id: Ibca52c3699ff3c09141e081c85f853781a86ec8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/687115
Auto-Submit: Joseph Tsai &lt;joetsai@digital-static.net&gt;
Reviewed-by: Carlos Amedee &lt;carlos@golang.org&gt;
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
Reviewed-by: Damien Neil &lt;dneil@google.com&gt;
</content>
</entry>
<entry>
<title>encoding/json/v2: reject unquoted dash as a JSON field name</title>
<updated>2025-06-24T13:41:42Z</updated>
<author>
<name>Joe Tsai</name>
<email>joetsai@digital-static.net</email>
</author>
<published>2025-06-22T04:27:09Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=2e9bb62bfed92ef24a6744fbdc3cf24eb672cd56'/>
<id>urn:sha1:2e9bb62bfed92ef24a6744fbdc3cf24eb672cd56</id>
<content type='text'>
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 &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
Reviewed-by: Johan Brandhorst-Satzkorn &lt;johan.brandhorst@gmail.com&gt;
Reviewed-by: Damien Neil &lt;dneil@google.com&gt;
Auto-Submit: Joseph Tsai &lt;joetsai@digital-static.net&gt;
Reviewed-by: Daniel Martí &lt;mvdan@mvdan.cc&gt;
Reviewed-by: Dmitri Shuralyov &lt;dmitshur@google.com&gt;
</content>
</entry>
<entry>
<title>encoding/json: add json/v2 with GOEXPERIMENT=jsonv2 guard</title>
<updated>2025-04-18T15:24:07Z</updated>
<author>
<name>Damien Neil</name>
<email>dneil@google.com</email>
</author>
<published>2025-04-11T21:19:51Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=0e17905793cb5e0acc323a0cdf3733199d93976a'/>
<id>urn:sha1:0e17905793cb5e0acc323a0cdf3733199d93976a</id>
<content type='text'>
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 &lt;dneil@google.com&gt;
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
Reviewed-by: Michael Pratt &lt;mpratt@google.com&gt;
Reviewed-by: Joseph Tsai &lt;joetsai@digital-static.net&gt;
Reviewed-by: Dmitri Shuralyov &lt;dmitshur@google.com&gt;
</content>
</entry>
<entry>
<title>encoding/json: cleanup tests</title>
<updated>2025-01-14T22:54:07Z</updated>
<author>
<name>Joe Tsai</name>
<email>joetsai@digital-static.net</email>
</author>
<published>2025-01-14T20:43:27Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=368a9ec99834652ca3f7d8fe24862a7581e12358'/>
<id>urn:sha1:368a9ec99834652ca3f7d8fe24862a7581e12358</id>
<content type='text'>
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 &lt;dneil@google.com&gt;
Auto-Submit: Joseph Tsai &lt;joetsai@digital-static.net&gt;
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
</content>
</entry>
<entry>
<title>encoding/json: add cases to TestUnmarshal for fatal syntactic errors</title>
<updated>2025-01-13T16:27:22Z</updated>
<author>
<name>Joe Tsai</name>
<email>joetsai@digital-static.net</email>
</author>
<published>2025-01-11T20:48:33Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=47a56b2b6d2cca56384810027964968667b86fdc'/>
<id>urn:sha1:47a56b2b6d2cca56384810027964968667b86fdc</id>
<content type='text'>
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 &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
Auto-Submit: Joseph Tsai &lt;joetsai@digital-static.net&gt;
Reviewed-by: Michael Knyszek &lt;mknyszek@google.com&gt;
</content>
</entry>
<entry>
<title>encoding/json: always check resulting Go value for unmarshaling</title>
<updated>2025-01-13T16:27:19Z</updated>
<author>
<name>Joe Tsai</name>
<email>joetsai@digital-static.net</email>
</author>
<published>2025-01-10T19:49:07Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=7bb192a1c56e2961b3eeffb8250615e395c903d4'/>
<id>urn:sha1:7bb192a1c56e2961b3eeffb8250615e395c903d4</id>
<content type='text'>
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 &lt;joetsai@digital-static.net&gt;
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
Reviewed-by: Michael Knyszek &lt;mknyszek@google.com&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
</content>
</entry>
<entry>
<title>encoding/json: improve fidelity of TestUnmarshal for Numbers</title>
<updated>2025-01-08T22:37:21Z</updated>
<author>
<name>Joe Tsai</name>
<email>joetsai@digital-static.net</email>
</author>
<published>2025-01-08T20:30:01Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=4225c6cb372e0fea7586dd646e991faa5df20671'/>
<id>urn:sha1:4225c6cb372e0fea7586dd646e991faa5df20671</id>
<content type='text'>
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 &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
Auto-Submit: Joseph Tsai &lt;joetsai@digital-static.net&gt;
Reviewed-by: Damien Neil &lt;dneil@google.com&gt;
Reviewed-by: Dmitri Shuralyov &lt;dmitshur@google.com&gt;
</content>
</entry>
<entry>
<title>encoding/json: expand and modernize TestInterfaceSet</title>
<updated>2024-12-28T01:23:24Z</updated>
<author>
<name>Joe Tsai</name>
<email>joetsai@digital-static.net</email>
</author>
<published>2024-12-23T18:35:24Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=2b794ed86cb1b718bc212ee90fecbb8f3b28a744'/>
<id>urn:sha1:2b794ed86cb1b718bc212ee90fecbb8f3b28a744</id>
<content type='text'>
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í &lt;mvdan@mvdan.cc&gt;
Reviewed-by: Damien Neil &lt;dneil@google.com&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
</content>
</entry>
<entry>
<title>encoding/json: check exact structure of local error types in tests</title>
<updated>2024-11-19T18:48:19Z</updated>
<author>
<name>Joe Tsai</name>
<email>joetsai@digital-static.net</email>
</author>
<published>2024-11-19T01:34:06Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=99dad5281660c4e644602e0c8790dd24b3eb45f3'/>
<id>urn:sha1:99dad5281660c4e644602e0c8790dd24b3eb45f3</id>
<content type='text'>
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 &lt;dneil@google.com&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
Reviewed-by: Daniel Martí &lt;mvdan@mvdan.cc&gt;
Reviewed-by: Damien Neil &lt;dneil@google.com&gt;
LUCI-TryBot-Result: Go LUCI &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
</content>
</entry>
<entry>
<title>encoding/json: add embedded structs to the UnmarshalTypeError's Field</title>
<updated>2024-09-03T15:49:47Z</updated>
<author>
<name>j2gg0s</name>
<email>j2gg0s@gmail.com</email>
</author>
<published>2024-08-27T14:35:59Z</published>
<link rel='alternate' type='text/html' href='http://git.kilabit.info/go/commit/?id=0fe6347732bdb9918e3af4e0c4b52f7f0c162894'/>
<id>urn:sha1:0fe6347732bdb9918e3af4e0c4b52f7f0c162894</id>
<content type='text'>
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 &lt;golang-scoped@luci-project-accounts.iam.gserviceaccount.com&gt;
Auto-Submit: Ian Lance Taylor &lt;iant@google.com&gt;
Reviewed-by: Ian Lance Taylor &lt;iant@google.com&gt;
Reviewed-by: Dmitri Shuralyov &lt;dmitshur@google.com&gt;
</content>
</entry>
</feed>
