diff options
Diffstat (limited to 'rrdformat/rrdbinary/decode.go')
-rw-r--r-- | rrdformat/rrdbinary/decode.go | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/rrdformat/rrdbinary/decode.go b/rrdformat/rrdbinary/decode.go index f3ae80e..cdaf49e 100644 --- a/rrdformat/rrdbinary/decode.go +++ b/rrdformat/rrdbinary/decode.go @@ -51,13 +51,16 @@ func (d *Decoder) Decode(ptr interface{}, tag string) error { if ptrValue.Kind() != reflect.Ptr { return typeErrorf("ptr is a %v, not a pointer", ptrValue.Kind()) } - return d.decode(ptrValue, tag) + return d.decode(ptrValue.Elem(), tag) } func (d *Decoder) decode(v reflect.Value, tag string) error { - if v.CanInterface() { - if u, ok := v.Interface().(unmarshaler); ok { - return u.unmarshalRRD(d, tag) + if v.Kind() != reflect.Ptr && v.CanAddr() { + vptr := v.Addr() + if vptr.CanInterface() { + if u, ok := vptr.Interface().(unmarshaler); ok { + return u.unmarshalRRD(d, tag) + } } } switch v.Type().Kind() { |