MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / readLine

Method readLine

pkg/util/encoding/csv/reader.go:229–248  ·  view source on GitHub ↗

readLine reads the next line (with the trailing endline). If EOF is hit without a trailing endline, it will be omitted. If some bytes were read, then the error is never io.EOF. The result is only valid until the next call to readLine.

()

Source from the content-addressed store, hash-verified

227// If some bytes were read, then the error is never io.EOF.
228// The result is only valid until the next call to readLine.
229func (r *Reader) readLine() ([]byte, error) {
230 line, err := r.r.ReadSlice('\n')
231 if err == bufio.ErrBufferFull {
232 r.rawBuffer = append(r.rawBuffer[:0], line...)
233 for err == bufio.ErrBufferFull {
234 line, err = r.r.ReadSlice('\n')
235 r.rawBuffer = append(r.rawBuffer, line...)
236 }
237 line = r.rawBuffer
238 }
239 if len(line) > 0 && err == io.EOF {
240 err = nil
241 // For backwards compatibility, drop trailing \r before EOF.
242 if line[len(line)-1] == '\r' {
243 line = line[:len(line)-1]
244 }
245 }
246 r.numLine++
247 return line, err
248}
249
250// lengthCRLF reports the number of bytes for a trailing "\r\n".
251func lengthCRLF(b []byte) int {

Callers 1

readRecordMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected