]> Cypherpunks repositories - gostls13.git/commit
encoding/csv: report line start line in errors
authorJustin Nuß <nuss.justin@gmail.com>
Wed, 2 Aug 2017 17:18:30 +0000 (19:18 +0200)
committerIan Lance Taylor <iant@golang.org>
Mon, 14 Aug 2017 04:45:38 +0000 (04:45 +0000)
commit5d14ac74f614631a38be95cc9724ff38068c6c76
treedec1fcac0d9ff56992966bdf4c0f68f154579843
parent342d25fc05a915f267e9d4f0bdc13fb04e014a2b
encoding/csv: report line start line in errors

Errors returned by Reader contain the line where the Reader originally
encountered the error. This can be suboptimal since that line does not
always correspond with the line the current record/field started at.

This can easily happen with LazyQuotes as seen in #19019, but also
happens for example when a quoted fields has no closing quote and
the parser hits EOF before it finds another quote.

When this happens finding the erroneous field can be somewhat
complicated and time consuming, and in most cases it would be better to
report the line where the record started.

This change updates Reader to keep track of the line on which a record
begins and uses it for errors instead of the current line, making it
easier to find errors.

Although a user-visible change, this should have no impact on existing
code, since most users don't explicitly work with the line in the error
and probably already expect the new behaviour.

Updates #19019

Change-Id: Ic9bc70fad2651c69435d614d537e7a9266819b05
Reviewed-on: https://go-review.googlesource.com/52830
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/encoding/csv/reader.go
src/encoding/csv/reader_test.go