From bcde7cc1f52cf2a3f125c9dbbd57772ee0db1c1f Mon Sep 17 00:00:00 2001 From: 2joy Date: Tue, 12 Feb 2019 21:40:20 +0700 Subject: [PATCH] Fixed crash when there are trailing delimiters at the end of a line --- reader.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/reader.go b/reader.go index 7e6cc86..6110673 100644 --- a/reader.go +++ b/reader.go @@ -92,6 +92,16 @@ func (r *Reader) Read() ([]string, error) { return record, err } else { r.skipDelimiter() + + // A line terminator follows immediately after a delimiter. + if nextIsLineTerminator, _ := r.nextIsLineTerminator(); nextIsLineTerminator { + // Skipping so that next read call is good to go. + err = r.skipLineTerminator() + // Error is not expected since it should be in the Unreader buffer, but + // might as well return it just in case. + record = append(record, "") + return record, err + } } }