ReadBytes reads until the first occurrence of delim in the input, returning a slice containing the data up to and including the delimiter. If ReadBytes encounters an error before finding a delimiter, it returns the data read before the error and the error itself (often io.EOF). ReadBytes returns err
(delim byte)
| 370 | // ReadBytes returns err != nil if and only if the returned data does not end in |
| 371 | // delim. |
| 372 | func (b *Buffer) ReadBytes(delim byte) (line []byte, err error) { |
| 373 | slice, err := b.readSlice(delim) |
| 374 | // return a copy of slice. The buffer's backing array may |
| 375 | // be overwritten by later calls. |
| 376 | line = append(line, slice...) |
| 377 | return |
| 378 | } |
| 379 | |
| 380 | // readSlice is like ReadBytes but returns a reference to internal buffer data. |
| 381 | func (b *Buffer) readSlice(delim byte) (line []byte, err error) { |