io: add support for pointer receivers in WriteArray()

It's actually preferable to have pointer receivers for serializable types, so
this should be supported.
This commit is contained in:
Roman Khimov 2019-12-09 16:57:25 +03:00
parent 052ba1e94f
commit b542a5e7a0
2 changed files with 26 additions and 1 deletions

View file

@ -49,7 +49,10 @@ func (w *BinWriter) WriteArray(arr interface{}) {
for i := 0; i < val.Len(); i++ {
el, ok := val.Index(i).Interface().(encodable)
if !ok {
panic(typ.String() + "is not encodable")
el, ok = val.Index(i).Addr().Interface().(encodable)
if !ok {
panic(typ.String() + " is not encodable")
}
}
el.EncodeBinary(w)