func (lr *Reader) Read(p []byte) (n int, err error) {
	if lr == nil {
		return 0, ErrNilReader
	}
	var (
		bufErr, filterErr error
		lineBytes         []byte
	)
	for lr.existsData && bufErr == nil && lr.buffer.Len() < bufferSizeLimit {
		if lr.existsData = lr.scanner.Scan(); !lr.existsData {
			break
		}
		lineBytes = lr.scanner.Bytes()
		lr.awkVars.NR++
		for _, filterFunc := range lr.filterFuncs {
			lineBytes, filterErr = filterFunc(lineBytes)
			if filterErr != nil {
				switch filterErr {
				case ErrOmitLine:
					lineBytes = nullBytes
				default:
					bufErr = filterErr
				}
				break
			}
		}
		_, _ = lr.buffer.Write(lineBytes)  
	}
	if !lr.existsData && bufErr == nil {
		bufErr = lr.scanner.Err()
	}
	n, err = lr.buffer.Read(p)
	if err != nil && bufErr == nil {
		bufErr = err
	}
	return n, bufErr
}
Read - implement io.Reader interface
package byline
import (
	"bufio"
	"bytes"
	"errors"
	"io"
	"io/ioutil"
	"regexp"
)
var (
	ErrOmitLine = errors.New("ErrOmitLine")
	ErrNilReader = errors.New("nil reader")
	defaultFS = regexp.MustCompile(`\s+`)
	defaultRS byte = '\n'
	nullBytes = []byte{}
	bufferSizeLimit = 512
)
type Reader struct {
	scanner     *bufio.Scanner
	buffer      bytes.Buffer
	existsData  bool
	filterFuncs []func(line []byte) ([]byte, error)
	awkVars     AWKVars
}
type AWKVars struct {
	NR int             
	NF int             
	RS byte            
	FS *regexp.Regexp  
}
func NewReader(reader io.Reader) *Reader {
	if reader == nil {
		return nil
	}
	lr := &Reader{
		scanner:    bufio.NewScanner(reader),
		existsData: true,
		awkVars: AWKVars{
			RS: defaultRS,
			FS: defaultFS,
		},
	}
	lr.scanner.Split(lr.scanLinesBySep)
	lr.buffer.Grow(bufferSizeLimit)
	return lr
}
func (lr *Reader) scanLinesBySep(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}
	if i := bytes.IndexByte(data, lr.awkVars.RS); i >= 0 {
		return i + 1, data[0 : i+1], nil
	}
	if atEOF {
		return len(data), data, nil
	}
	return 0, nil, nil
}