Documentation
¶
Overview ¶
Package detect provides types that perform string detection and replacement on byte streams.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HashModuloReader ¶
type HashModuloReader struct {
// contains filtered or unexported fields
}
HashModuloReader wraps an underlying reader to replace any occurrences of a search string with a same-sized replacement string and record the offsets of those occurrences.
func NewHashModuloReader ¶
func NewHashModuloReader(old, new string, r io.Reader) *HashModuloReader
NewHashModuloReader returns a new HashModuloReader that reads from r and replaces old with new. NewHashModuloReader panics if len(old) != len(new).
func (*HashModuloReader) Offsets ¶
func (hmr *HashModuloReader) Offsets() []int64
Offsets returns a list of the offsets in the reader where the search string has occurred in ascending order.
func (*HashModuloReader) Read ¶
func (hmr *HashModuloReader) Read(p []byte) (n int, err error)
Read implements io.Reader. Read may read more bytes from the underlying reader than the number of bytes returned to the caller in order to determine whether the bytes are part of the reader's search string.
type RefFinder ¶
type RefFinder struct {
// contains filtered or unexported fields
}
A RefFinder records which elements in a set of search strings occur in a byte stream.
func NewRefFinder ¶
NewRefFinder returns a new RefFinder that searches for strings from the given sequence.
func (*RefFinder) Write ¶
Write implements io.Writer by recording any occurrences of the strings the RefFinder is searching for that are found in p. The bytes written to the RefFinder are considered a contiguous stream: occurrences may span multiple calls to Write or RefFinder.WriteString.
func (*RefFinder) WriteString ¶
WriteString implements io.StringWriter by recording any occurrences of the strings the RefFinder is searching for that are found in s. The bytes written to the RefFinder are considered a contiguous stream: occurrences may span multiple calls to WriteString or RefFinder.Write.