From 9a15ccd5567a72b653390ce63e77b7f3446dd059 Mon Sep 17 00:00:00 2001 From: Florian Lehner Date: Tue, 8 Mar 2022 20:55:40 +0100 Subject: [PATCH] fix inital buffer size (#129) Correctly handle maxBufferSize for scanner buffer --- event.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/event.go b/event.go index 0d65c0e..e65a523 100644 --- a/event.go +++ b/event.go @@ -29,7 +29,8 @@ type EventStreamReader struct { // NewEventStreamReader creates an instance of EventStreamReader. func NewEventStreamReader(eventStream io.Reader, maxBufferSize int) *EventStreamReader { scanner := bufio.NewScanner(eventStream) - scanner.Buffer(make([]byte, 4096), maxBufferSize) + initBufferSize := minPosInt(4096, maxBufferSize) + scanner.Buffer(make([]byte, initBufferSize), maxBufferSize) split := func(data []byte, atEOF bool) (int, []byte, error) { if atEOF && len(data) == 0 {