• Joe Tsai's avatar
    encoding/csv: add ParseError.RecordLine · 29ea82d0
    Joe Tsai authored
    CL 72150 fixes #22352 by reverting the problematic parts of that CL
    where the line number and column number were inconsistent with each other.
    This CL adds back functionality to address the issue that CL 72150
    was trying to solve in the first place. That is, it reports the starting
    line of the record, so that users have a frame of reference to start with
    when debugging what went wrong.
    
    In the event of gnarly CSV files with multiline quoted strings, a parse
    failure likely occurs somewhere between the start of the record and
    the point where the parser finally detected an error.
    Since ParserError.{Line,Column} reports where the *error* occurs, we
    add a RecordLine field to report where the record starts.
    
    Also take this time to cleanup and modernize TestRead.
    
    Fixes #19019
    Fixes #22352
    
    Change-Id: I16cebf0b81922c35f75804c7073e9cddbfd11a04
    Reviewed-on: https://go-review.googlesource.com/72310Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
    29ea82d0
reader.go 11.3 KB