readUntil reads bytes to the buffer until the specified delimiter byte is encountered. The delimiter byte is included in the buffer. If an error occurs, it sets d.err and returns false.
(delim byte)
| 740 | // The delimiter byte is included in the buffer. |
| 741 | // If an error occurs, it sets d.err and returns false. |
| 742 | func (d *Decoder) readUntil(delim byte) bool { |
| 743 | for { |
| 744 | b, err := d.r.ReadSlice(delim) |
| 745 | if err != nil && !errors.Is(err, bufio.ErrBufferFull) && !errors.Is(err, io.EOF) { |
| 746 | d.err = err |
| 747 | return false |
| 748 | } |
| 749 | |
| 750 | d.buf.Write(b) |
| 751 | d.countNewLines(b) |
| 752 | |
| 753 | if err == nil { |
| 754 | // We've read up to the delimiter byte, break the loop. |
| 755 | return true |
| 756 | } |
| 757 | |
| 758 | if err == io.EOF { |
| 759 | // Reached EOF without finding the delimiter. |
| 760 | d.err = err |
| 761 | return false |
| 762 | } |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | // mustReadUntil reads bytes to the buffer until the specified delimiter byte is encountered. |
| 767 | // The delimiter byte is included in the buffer. |
no test coverage detected