diff options
| author | j2gg0s <j2gg0s@gmail.com> | 2024-08-27 14:35:59 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2024-09-03 15:49:47 +0000 |
| commit | 0fe6347732bdb9918e3af4e0c4b52f7f0c162894 (patch) | |
| tree | f1e0b1a1f2a15e75ec0d4c84a795eaa98a443044 /src/encoding/json/decode_test.go | |
| parent | 3da6c94d5ed62bf0c7fe682dcf46a1e53b72c2d9 (diff) | |
| download | go-0fe6347732bdb9918e3af4e0c4b52f7f0c162894.tar.xz | |
encoding/json: add embedded structs to the UnmarshalTypeError's Field
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>
Diffstat (limited to 'src/encoding/json/decode_test.go')
| -rw-r--r-- | src/encoding/json/decode_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/encoding/json/decode_test.go b/src/encoding/json/decode_test.go index 752825cffe..71895a9bb1 100644 --- a/src/encoding/json/decode_test.go +++ b/src/encoding/json/decode_test.go @@ -898,6 +898,19 @@ var unmarshalTests = []struct { }, }, + { + CaseName: Name(""), + in: `{"Level1a": "hello"}`, + ptr: new(Top), + err: &UnmarshalTypeError{ + Value: "string", + Struct: "Top", + Field: "Embed0a.Level1a", + Type: reflect.TypeFor[int](), + Offset: 10, + }, + }, + // issue 15146. // invalid inputs in wrongStringTests below. {CaseName: Name(""), in: `{"B":"true"}`, ptr: new(B), out: B{true}, golden: true}, |
