diff options
| author | Ian Lance Taylor <iant@golang.org> | 2023-07-31 15:18:12 -0700 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-08-01 14:30:02 +0000 |
| commit | 56d3e84bb0195913e1d932d6fe8251047091076b (patch) | |
| tree | 7dd24d6872c1ce6ef7b167af5cfc88f1991ecb5e /src/encoding/json/encode.go | |
| parent | db25bc19e5221c7df2caed3b1daeda673ec757d9 (diff) | |
| download | go-56d3e84bb0195913e1d932d6fe8251047091076b.tar.xz | |
encoding/json: use reflect.TypeFor for known types
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>
Diffstat (limited to 'src/encoding/json/encode.go')
| -rw-r--r-- | src/encoding/json/encode.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/encoding/json/encode.go b/src/encoding/json/encode.go index 614662d54b..bba57fdf4f 100644 --- a/src/encoding/json/encode.go +++ b/src/encoding/json/encode.go @@ -371,8 +371,8 @@ func typeEncoder(t reflect.Type) encoderFunc { } var ( - marshalerType = reflect.TypeOf((*Marshaler)(nil)).Elem() - textMarshalerType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem() + marshalerType = reflect.TypeFor[Marshaler]() + textMarshalerType = reflect.TypeFor[encoding.TextMarshaler]() ) // newTypeEncoder constructs an encoderFunc for a type. |
