From 30651b3bbbfda86e8188dfd89cb326a4db085e25 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 26 Oct 2016 12:22:16 -0400 Subject: [PATCH] encoding/csv: document Read error behavior Fixes #17342. Change-Id: I76af756d7aff464554c5564d444962a468d0eccc Reviewed-on: https://go-review.googlesource.com/32172 Run-TryBot: Russ Cox Reviewed-by: Quentin Smith --- src/encoding/csv/reader.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/encoding/csv/reader.go b/src/encoding/csv/reader.go index 28caa6aa27..c8c4ca7758 100644 --- a/src/encoding/csv/reader.go +++ b/src/encoding/csv/reader.go @@ -141,8 +141,12 @@ func (r *Reader) error(err error) error { } } -// Read reads one record from r. The record is a slice of strings with each -// string representing one field. +// Read reads one record (a slice of fields) from r. +// If the record has an unexpected number of fields, +// Read returns the record along with the error ErrFieldCount. +// Except for that case, Read always returns either a non-nil +// record or a non-nil error, but not both. +// If there is no data left to be read, Read returns nil, io.EOF. func (r *Reader) Read() (record []string, err error) { for { record, err = r.parseRecord()