summaryrefslogtreecommitdiff
path: root/rrdformat/rrdbinary/decode.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2020-01-27 23:09:48 -0500
committerLuke Shumaker <lukeshu@lukeshu.com>2020-01-27 23:09:48 -0500
commit140ad92a3bbab485ef0f27c7be03d62d10ffd067 (patch)
treef3954785f43680acd90f0e741be44448dfa24ad2 /rrdformat/rrdbinary/decode.go
parenta047b135ca416584178a6adde64cc156ab637431 (diff)
fix
Diffstat (limited to 'rrdformat/rrdbinary/decode.go')
-rw-r--r--rrdformat/rrdbinary/decode.go11
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() {