internal/proto: cleanup code

This commit is contained in:
Vladimir Mihailenco 2018-03-08 14:00:21 +02:00
parent 46dd7afbbf
commit 3aa80da654
1 changed files with 8 additions and 10 deletions

View File

@ -71,17 +71,15 @@ func (w *WriteBuffer) append(val interface{}) error {
} else {
w.AppendString("0")
}
default:
if bm, ok := val.(encoding.BinaryMarshaler); ok {
bb, err := bm.MarshalBinary()
if err != nil {
return err
}
w.AppendBytes(bb)
} else {
return fmt.Errorf(
"redis: can't marshal %T (consider implementing encoding.BinaryMarshaler)", val)
case encoding.BinaryMarshaler:
b, err := v.MarshalBinary()
if err != nil {
return err
}
w.AppendBytes(b)
default:
return fmt.Errorf(
"redis: can't marshal %T (consider implementing encoding.BinaryMarshaler)", val)
}
return nil
}