readSlice is like ReadBytes but returns a reference to internal buffer data.
(delim byte)
| 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) { |
| 382 | i := bytes.IndexByte(b.buf[b.off:], delim) |
| 383 | end := b.off + i + 1 |
| 384 | if i < 0 { |
| 385 | end = len(b.buf) |
| 386 | err = io.EOF |
| 387 | } |
| 388 | line = b.buf[b.off:end] |
| 389 | b.off = end |
| 390 | return line, err |
| 391 | } |
| 392 | |
| 393 | // ReadString reads until the first occurrence of delim in the input, |
| 394 | // returning a string containing the data up to and including the delimiter. |
no outgoing calls
no test coverage detected