From 46de3ae9a9ec60ef840b59ce3c4c8a96204807c6 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Mon, 10 Jun 2019 12:42:43 +0100 Subject: [PATCH] Fix text codec --- codec/text/text.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/codec/text/text.go b/codec/text/text.go index f6f28859..da43da50 100644 --- a/codec/text/text.go +++ b/codec/text/text.go @@ -30,6 +30,9 @@ func (c *Codec) ReadBody(b interface{}) error { } switch b.(type) { + case *string: + v := b.(*string) + *v = string(buf) case *[]byte: v := b.(*[]byte) *v = buf @@ -51,6 +54,12 @@ func (c *Codec) Write(m *codec.Message, b interface{}) error { case *[]byte: ve := b.(*[]byte) v = *ve + case *string: + ve := b.(*string) + v = []byte(*ve) + case string: + ve := b.(string) + v = []byte(ve) case []byte: v = b.([]byte) default: @@ -65,7 +74,7 @@ func (c *Codec) Close() error { } func (c *Codec) String() string { - return "bytes" + return "text" } func NewCodec(c io.ReadWriteCloser) codec.Codec {