From ec884b0ee8898c21747af5ae698411c44dcf5765 Mon Sep 17 00:00:00 2001 From: KevRiver Date: Thu, 7 Nov 2024 03:34:00 +0900 Subject: [PATCH] feat(scanner): fix Scan function --- scanner.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scanner.go b/scanner.go index 65d74dd..e0b9f1c 100644 --- a/scanner.go +++ b/scanner.go @@ -32,6 +32,7 @@ func Scan(ctx context.Context, src io.Reader, sink sink.Sink, opts *HandlerOptio data := new(typesv1.StructuredLogEvent) ev.Structured = data + skipNextScan := false for { if !in.Scan() { err := in.Err() @@ -42,11 +43,15 @@ func Scan(ctx context.Context, src io.Reader, sink sink.Sink, opts *HandlerOptio in = bufio.NewScanner(src) in.Buffer(make([]byte, 0, maxBufferSize), maxBufferSize) in.Split(bufio.ScanLines) - in.Scan() + skipNextScan = true continue } break } + if skipNextScan { + skipNextScan = false + continue + } line++ lineData := in.Bytes()