ReadAll reads all the remaining records from r. Each record is a slice of fields. A successful call returns err == nil, not err == io.EOF. Because ReadAll is defined to read until EOF, it does not treat end of file as an error to be reported.
()
| 210 | // defined to read until EOF, it does not treat end of file as an error to be |
| 211 | // reported. |
| 212 | func (r *Reader) ReadAll() (records [][]string, err error) { |
| 213 | for { |
| 214 | record, err := r.readRecord(nil) |
| 215 | if err == io.EOF { |
| 216 | return records, nil |
| 217 | } |
| 218 | if err != nil { |
| 219 | return nil, err |
| 220 | } |
| 221 | records = append(records, record) |
| 222 | } |
| 223 | } |
| 224 | |
| 225 | // readLine reads the next line (with the trailing endline). |
| 226 | // If EOF is hit without a trailing endline, it will be omitted. |