From: Jess Frazelle Date: Fri, 20 May 2016 21:35:28 +0000 (-0700) Subject: encoding/csv: update doc about comments whitespace X-Git-Tag: go1.7beta2~27 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=8042bfe347d5b2c4f6af372b09b23c8945fb196e;p=gostls13.git encoding/csv: update doc about comments whitespace This patch updates the doc about comments whitespace for the encoding/csv package to reflect that leading whitespace before the hash will treat the line as not a comment. Fixes #13775. Change-Id: Ia468c75b242a487b4b2b4cd3d342bfb8e07720ba Reviewed-on: https://go-review.googlesource.com/23302 Reviewed-by: Ian Lance Taylor --- diff --git a/src/encoding/csv/reader.go b/src/encoding/csv/reader.go index 89283bb303..a5e03a9f8e 100644 --- a/src/encoding/csv/reader.go +++ b/src/encoding/csv/reader.go @@ -86,34 +86,35 @@ var ( // The exported fields can be changed to customize the details before the // first call to Read or ReadAll. // -// Comma is the field delimiter. It defaults to ','. // -// Comment, if not 0, is the comment character. Lines beginning with the -// Comment character are ignored. -// -// If FieldsPerRecord is positive, Read requires each record to -// have the given number of fields. If FieldsPerRecord is 0, Read sets it to -// the number of fields in the first record, so that future records must -// have the same field count. If FieldsPerRecord is negative, no check is -// made and records may have a variable number of fields. -// -// If LazyQuotes is true, a quote may appear in an unquoted field and a -// non-doubled quote may appear in a quoted field. -// -// If TrimLeadingSpace is true, leading white space in a field is ignored. -// If the field delimiter is white space, TrimLeadingSpace will trim the -// delimiter. type Reader struct { - Comma rune // field delimiter (set to ',' by NewReader) - Comment rune // comment character for start of line - FieldsPerRecord int // number of expected fields per record - LazyQuotes bool // allow lazy quotes - TrailingComma bool // ignored; here for backwards compatibility - TrimLeadingSpace bool // trim leading space - line int - column int - r *bufio.Reader - field bytes.Buffer + // Comma is the field delimiter. + // It is set to comma (',') by NewReader. + Comma rune + // Comment, if not 0, is the comment character. Lines beginning with the + // Comment character without preceding whitespace are ignored. + // With leading whitespace the Comment character becomes part of the + // field, even if TrimLeadingSpace is true. + Comment rune + // FieldsPerRecord is the number of expected fields per record. + // If FieldsPerRecord is positive, Read requires each record to + // have the given number of fields. If FieldsPerRecord is 0, Read sets it to + // the number of fields in the first record, so that future records must + // have the same field count. If FieldsPerRecord is negative, no check is + // made and records may have a variable number of fields. + FieldsPerRecord int + // If LazyQuotes is true, a quote may appear in an unquoted field and a + // non-doubled quote may appear in a quoted field. + LazyQuotes bool + TrailingComma bool // ignored; here for backwards compatibility + // If TrimLeadingSpace is true, leading white space in a field is ignored. + // This is done even if the field delimiter, Comma, is white space. + TrimLeadingSpace bool + + line int + column int + r *bufio.Reader + field bytes.Buffer } // NewReader returns a new Reader that reads from r.