mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
json: fix []unmarshaler case
Now that reflect has v.Addr(), we can use it. R=golang-dev, dsymonds, r CC=golang-dev https://golang.org/cl/4860041
This commit is contained in:
parent
c9cf04a9f6
commit
83c734601c
2 changed files with 16 additions and 1 deletions
|
|
@ -251,6 +251,12 @@ func (d *decodeState) value(v reflect.Value) {
|
|||
// if it encounters an Unmarshaler, indirect stops and returns that.
|
||||
// if wantptr is true, indirect stops at the last pointer.
|
||||
func (d *decodeState) indirect(v reflect.Value, wantptr bool) (Unmarshaler, reflect.Value) {
|
||||
// If v is a named type and is addressable,
|
||||
// start with its address, so that if the type has pointer methods,
|
||||
// we find them.
|
||||
if v.Kind() != reflect.Ptr && v.Type().Name() != "" && v.CanAddr() {
|
||||
v = v.Addr()
|
||||
}
|
||||
for {
|
||||
var isUnmarshaler bool
|
||||
if v.Type().NumMethod() > 0 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue