aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/json/v2/example_test.go
diff options
context:
space:
mode:
authorJoe Tsai <joetsai@digital-static.net>2025-10-24 10:55:48 -0700
committerGopher Robot <gobot@golang.org>2025-10-24 11:49:08 -0700
commit747fe2efedfdc43f797b4fc1672e29ff7a01ec6a (patch)
treebccd13b998a16630f4c4c191ddaa1e4622ffe2ed /src/encoding/json/v2/example_test.go
parent94f47fc03f4c916decb7f1387fcf56eae388f7cf (diff)
downloadgo-747fe2efedfdc43f797b4fc1672e29ff7a01ec6a.tar.xz
encoding/json/v2: fix typo in documentation about errors.AsType
CL 708495 mass migrated the stdlib to use errors.AsType. It rewrote the documentation, but uses the non-pointer type of SemanticError or SyntacticError, which is invalid since the Error method is declared on the pointer receiver. Also, call errors.AsType on a separate line for readability. Change-Id: I2eaf59614e2b58aa4bc8669ab81ce64168c54f13 Reviewed-on: https://go-review.googlesource.com/c/go/+/714660 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Auto-Submit: Joseph Tsai <joetsai@digital-static.net> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/encoding/json/v2/example_test.go')
-rw-r--r--src/encoding/json/v2/example_test.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/encoding/json/v2/example_test.go b/src/encoding/json/v2/example_test.go
index 6d539bbd36..dc1f06674c 100644
--- a/src/encoding/json/v2/example_test.go
+++ b/src/encoding/json/v2/example_test.go
@@ -371,7 +371,8 @@ func Example_unknownMembers() {
// Specifying RejectUnknownMembers causes Unmarshal
// to reject the presence of any unknown members.
err = json.Unmarshal([]byte(input), new(Color), json.RejectUnknownMembers(true))
- if serr, ok := errors.AsType[*json.SemanticError](err); ok && serr.Err == json.ErrUnknownName {
+ serr, ok := errors.AsType[*json.SemanticError](err)
+ if ok && serr.Err == json.ErrUnknownName {
fmt.Println("Unmarshal error:", serr.Err, strconv.Quote(serr.JSONPointer.LastToken()))
}