func (b *Base) ReadLine() ([]byte, error) {
	d, err := b.Reader.ReadSlice('\n')
	if err == nil || err == io.EOF {
		bb := make([]byte, len(d))
		copy(bb, d)
		return bb, err
	}
	if err != bufio.ErrBufferFull {
		return nil, err
	}
	bb := bytes.Buffer{}
	if _, err := bb.Write(d); err != nil {
		return nil, err
	}
	for {
		b2, err := b.Reader.ReadSlice('\n')
		if len(b2) > 0 {
			if _, err := bb.Write(b2); err != nil {
				return nil, err
			}
		}
		if err == nil || err == io.EOF {
			return bb.Bytes(), nil
		}
		if err != bufio.ErrBufferFull {
			return nil, err
		}
	}
}
ReadLine reads a line as []byte.
package filter
import (
	"bufio"
	"bytes"
	"io"
)
type Base struct {
	Reader *bufio.Reader
	buf    bytes.Buffer
	closed bool
	raw    io.ReadCloser
	rn     BaseReadNext
}
type BaseReadNext func(buf *bytes.Buffer) error
func (b *Base) Init(r io.ReadCloser, readNext BaseReadNext) {
	b.Reader = bufio.NewReader(r)
	b.raw = r
	b.rn = readNext
}
func (b *Base) Read(buf []byte) (int, error) {
	if b.buf.Len() == 0 {
		if b.closed {
			return 0, io.EOF
		}
		b.buf.Reset()
		err := b.rn(&b.buf)
		if err == io.EOF {
			b.Close()
		} else if err != nil {
			return 0, err
		}
	}
	return b.buf.Read(buf)
}