mirror of
https://github.com/johnkerl/miller.git
synced 2026-01-23 02:14:13 +00:00
error-handling in the CSV-reader's constructor
This commit is contained in:
parent
8b524b3ada
commit
d2925aafe5
1 changed files with 6 additions and 1 deletions
|
|
@ -39,6 +39,11 @@ func NewRecordReaderCSV(
|
|||
if len(readerOptions.IFS) != 1 {
|
||||
return nil, fmt.Errorf("for CSV, IFS can only be a single character")
|
||||
}
|
||||
if readerOptions.CommentHandling != cli.CommentsAreData {
|
||||
if len(readerOptions.CommentString) != 1 {
|
||||
return nil, fmt.Errorf("for CSV, the comment prefix must be a single character")
|
||||
}
|
||||
}
|
||||
return &RecordReaderCSV{
|
||||
readerOptions: readerOptions,
|
||||
ifs0: readerOptions.IFS[0],
|
||||
|
|
@ -326,7 +331,7 @@ func (reader *RecordReaderCSV) maybeConsumeComment(
|
|||
// its Write method has pointer receiver. So we have a WorkaroundBuffer
|
||||
// struct below which has non-pointer receiver.
|
||||
|
||||
// Contract with our fork of the go-csv CSV Reader
|
||||
// Contract with our fork of the go-csv CSV Reader, and, our own constructor.
|
||||
lib.InternalCodingErrorIf(len(csvRecord) != 1)
|
||||
recordsAndContexts.PushBack(types.NewOutputString(csvRecord[0], context))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue