From 3aa80da65408aab8562a3447f9eb56d07174ab6b Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Thu, 8 Mar 2018 14:00:21 +0200 Subject: [PATCH] internal/proto: cleanup code --- internal/proto/write_buffer.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/internal/proto/write_buffer.go b/internal/proto/write_buffer.go index 096b6d7..cc4014f 100644 --- a/internal/proto/write_buffer.go +++ b/internal/proto/write_buffer.go @@ -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 }