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 { } else {
w.AppendString("0") w.AppendString("0")
} }
default: case encoding.BinaryMarshaler:
if bm, ok := val.(encoding.BinaryMarshaler); ok { b, err := v.MarshalBinary()
bb, err := bm.MarshalBinary() if err != nil {
if err != nil { return err
return err
}
w.AppendBytes(bb)
} else {
return fmt.Errorf(
"redis: can't marshal %T (consider implementing encoding.BinaryMarshaler)", val)
} }
w.AppendBytes(b)
default:
return fmt.Errorf(
"redis: can't marshal %T (consider implementing encoding.BinaryMarshaler)", val)
} }
return nil return nil
} }