gojay

high performance JSON encoder/decoder with stream API for Golang
git clone git://git.lair.cx/gojay
Log | Files | Refs | README | LICENSE

commit 827f71a3082744cae0178c5e51f88936eb575901
parent 77b2d39674ab75670f4173f8b9d6a46db75c49e4
Author: francoispqt <francois@parquet.ninja>
Date:   Wed,  9 May 2018 22:30:23 +0800

add tests for stream encoding

Diffstat:
Mencode.go | 5-----
Mencode_stream_pool_test.go | 3++-
2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/encode.go b/encode.go @@ -187,11 +187,6 @@ type Encoder struct { err error } -func (enc *Encoder) Init(w io.Writer) { - enc.w = w - enc.buf = make([]byte, 0, 512) -} - // AppendBytes allows a modular usage by appending bytes manually to the current state of the buffer. func (enc *Encoder) AppendBytes(b []byte) { enc.writeBytes(b) diff --git a/encode_stream_pool_test.go b/encode_stream_pool_test.go @@ -8,14 +8,15 @@ import ( ) func TestEncodeStreamBorrow1(t *testing.T) { + enc := streamEncPool.New().(*StreamEncoder) // we override the pool chan streamEncPool = sync.Pool{ New: func() interface{} { return Stream.NewEncoder(nil) }, } + enc = streamEncPool.New().(*StreamEncoder) // add one decoder to the channel - enc := Stream.NewEncoder(nil) streamEncPool.Put(enc) // reset streamEncPool streamEncPool = sync.Pool{