aboutsummaryrefslogtreecommitdiff
path: root/src/encoding/csv/reader.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2017-11-14 13:23:10 -0500
committerRuss Cox <rsc@golang.org>2017-11-15 21:26:52 +0000
commitc4c3f2a1f2d9ee0735aba1583bb2a3301ec790d3 (patch)
treee08d24089a784ece80eba485f438c7490ad3707a /src/encoding/csv/reader.go
parent9232a612fed58d2629073056f827db3fae0cd5f0 (diff)
downloadgo-c4c3f2a1f2d9ee0735aba1583bb2a3301ec790d3.tar.xz
encoding/csv: rename ParseError.RecordLine to .StartLine
A record can span multiple lines (the whole reason for the extra field), so the important fact is that it's the _start_ of the record. Make that clear in the name. (This API was added during the Go 1.10 cycle so it can still be cleaned up.) Change-Id: Id95b3ceb7cdfc4aa0ed5a053cb84da8945fa5496 Reviewed-on: https://go-review.googlesource.com/78119 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Diffstat (limited to 'src/encoding/csv/reader.go')
-rw-r--r--src/encoding/csv/reader.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/encoding/csv/reader.go b/src/encoding/csv/reader.go
index 031ee6cedb..09f0dac5d0 100644
--- a/src/encoding/csv/reader.go
+++ b/src/encoding/csv/reader.go
@@ -64,18 +64,18 @@ import (
// A ParseError is returned for parsing errors.
// Line numbers are 1-indexed and columns are 0-indexed.
type ParseError struct {
- RecordLine int // Line where the record starts
- Line int // Line where the error occurred
- Column int // Column (rune index) where the error occurred
- Err error // The actual error
+ StartLine int // Line where the record starts
+ Line int // Line where the error occurred
+ Column int // Column (rune index) where the error occurred
+ Err error // The actual error
}
func (e *ParseError) Error() string {
if e.Err == ErrFieldCount {
return fmt.Sprintf("record on line %d: %v", e.Line, e.Err)
}
- if e.RecordLine != e.Line {
- return fmt.Sprintf("record on line %d; parse error on line %d, column %d: %v", e.RecordLine, e.Line, e.Column, e.Err)
+ if e.StartLine != e.Line {
+ return fmt.Sprintf("record on line %d; parse error on line %d, column %d: %v", e.StartLine, e.Line, e.Column, e.Err)
}
return fmt.Sprintf("parse error on line %d, column %d: %v", e.Line, e.Column, e.Err)
}
@@ -287,7 +287,7 @@ parseField:
if !r.LazyQuotes {
if j := bytes.IndexByte(field, '"'); j >= 0 {
col := utf8.RuneCount(fullLine[:len(fullLine)-len(line[j:])])
- err = &ParseError{RecordLine: recLine, Line: r.numLine, Column: col, Err: ErrBareQuote}
+ err = &ParseError{StartLine: recLine, Line: r.numLine, Column: col, Err: ErrBareQuote}
break parseField
}
}
@@ -327,7 +327,7 @@ parseField:
default:
// `"*` sequence (invalid non-escaped quote).
col := utf8.RuneCount(fullLine[:len(fullLine)-len(line)-quoteLen])
- err = &ParseError{RecordLine: recLine, Line: r.numLine, Column: col, Err: ErrQuote}
+ err = &ParseError{StartLine: recLine, Line: r.numLine, Column: col, Err: ErrQuote}
break parseField
}
} else if len(line) > 0 {
@@ -345,7 +345,7 @@ parseField:
// Abrupt end of file (EOF or error).
if !r.LazyQuotes && errRead == nil {
col := utf8.RuneCount(fullLine)
- err = &ParseError{RecordLine: recLine, Line: r.numLine, Column: col, Err: ErrQuote}
+ err = &ParseError{StartLine: recLine, Line: r.numLine, Column: col, Err: ErrQuote}
break parseField
}
r.fieldIndexes = append(r.fieldIndexes, len(r.recordBuffer))
@@ -375,7 +375,7 @@ parseField:
// Check or update the expected fields per record.
if r.FieldsPerRecord > 0 {
if len(dst) != r.FieldsPerRecord && err == nil {
- err = &ParseError{RecordLine: recLine, Line: recLine, Err: ErrFieldCount}
+ err = &ParseError{StartLine: recLine, Line: recLine, Err: ErrFieldCount}
}
} else if r.FieldsPerRecord == 0 {
r.FieldsPerRecord = len(dst)