func (t text) run(dst []byte, up *reader) (int, error, state) { n, err := io.ReadFull(t.r, dst) if err == finder.Found { return n, nil, comment{finder.NewReader(up.end, up.r)} } return n, err, t }
func (c copier) run(dst []byte, up *reader) (int, error, state) { n := copy(dst, c) if n == len(c) { return n, nil, text{finder.NewReader(up.begin, up.r)} } return n, nil, c[n:] }
// NewCustomReader returns an io.Reader that copies directly from r, replacing // any string between begin and end with add. func NewCustomReader(r io.Reader, begin, end, add []byte) io.Reader { br, ok := r.(io.ByteReader) if !ok { br = bufio.NewReader(r) } ret := &reader{ r: br, begin: finder.Compile(begin), end: finder.Compile(end), add: add, } ret.state = text{finder.NewReader(ret.begin, ret.r)} return ret }