]> Cypherpunks repositories - gostls13.git/commitdiff
encoding/csv: update doc about comments whitespace
authorJess Frazelle <me@jessfraz.com>
Fri, 20 May 2016 21:35:28 +0000 (14:35 -0700)
committerIan Lance Taylor <iant@golang.org>
Fri, 10 Jun 2016 01:00:09 +0000 (01:00 +0000)
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 <iant@golang.org>
src/encoding/csv/reader.go

index 89283bb3031d4a2d9c919522567491e5e1c42578..a5e03a9f8ef670ea7956c6028f0bd1480f98e668 100644 (file)
@@ -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.