// Next advances to the next row.
//
// Returns true if the next row does exist.
//
// Next must be called after reading all the columns on the previous row.
// Check Error after Next returns false.
//
// HasCols may be used for reading rows with variable number of columns.
Next advances to the next row.

Returns true if the next row does exist.

Next must be called after reading all the columns on the previous row.
Check Error after Next returns false.

HasCols may be used for reading rows with variable number of columns.
// Next advances to the next row . // // Returns true if the next row does exist . // // Next must be called after reading all the columns on the previous row . // Check Error after Next returns false . // // HasCols may be used for reading rows with variable number of columns .
func (tr *Reader) Next() bool {
	if tr.err != nil {
		return false
	}
	if tr.HasCols() {
		tr.err = fmt.Errorf("row #%d %q contains unread columns: %q", tr.row, tr.rowBuf, tr.b)
		return false
	}
	tr.row++
	tr.col = 0
	tr.rowBuf = nil
	for {
		if len(tr.rb) == 0 {
			if tr.rErr != nil {
				tr.err = tr.rErr
				if tr.err != io.EOF {
					tr.err = fmt.Errorf("cannot read row #%d: %s", tr.row, tr.err)
				} else if len(tr.scratch) > 0 {
					tr.err = fmt.Errorf("cannot find newline at the end of row #%d; row: %q", tr.row, tr.scratch)
				}
				return false
			}
			n, err := tr.r.Read(tr.rBuf[:])
			tr.rb = tr.rBuf[:n]
			tr.needUnescape = (bytes.IndexByte(tr.rb, '\\') >= 0)
			tr.rErr = err
		}
		n := bytes.IndexByte(tr.rb, '\n')
		if n >= 0 {
			b := tr.rb[:n]
			tr.rb = tr.rb[n+1:]
			if len(tr.scratch) > 0 {
				tr.scratch = append(tr.scratch, b...)
				b = tr.scratch
				tr.scratch = tr.scratch[:0]
			}
			tr.rowBuf = b
			tr.b = tr.rowBuf
			return true
		}
		tr.scratch = append(tr.scratch, tr.rb...)
		tr.rb = nil
	}
}
func ( tr * Reader ) Next ( ) bool { if tr . err != nil { return false } if tr . HasCols ( ) { tr . err = fmt . Errorf ( " " , tr . row , tr . rowBuf , tr . b ) return false } tr . row ++ tr . col = 0 tr . rowBuf = nil for { if len ( tr . rb ) == 0 { if tr . rErr != nil { tr . err = tr . rErr if tr . err != io . EOF { tr . err = fmt . Errorf ( " " , tr . row , tr . err ) } else if len ( tr . scratch ) > 0 { tr . err = fmt . Errorf ( " " , tr . row , tr . scratch ) } return false } n , err := tr . r . Read ( tr . rBuf [ : ] ) tr . rb = tr . rBuf [ : n ] tr . needUnescape = ( bytes . IndexByte ( tr . rb , '\\' ) >= 0 ) tr . rErr = err } n := bytes . IndexByte ( tr . rb , '\n' ) if n >= 0 { b := tr . rb [ : n ] tr . rb = tr . rb [ n + 1 : ] if len ( tr . scratch ) > 0 { tr . scratch = append ( tr . scratch , b ... ) b = tr . scratch tr . scratch = tr . scratch [ : 0 ] } tr . rowBuf = b tr . b = tr . rowBuf return true } tr . scratch = append ( tr . scratch , tr . rb ... ) tr . rb = nil } }
Next advances to the next row.
Next advances to the next row .
// Read buffer is empty. Attempt to fill it. // Search for the end of the current row. // Fast path: the row has been found. // Slow path: cannot find the end of row. // Append tr.rb to tr.scratch and repeat.