Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNoMatch is returned when no match is found. ErrNoMatch = errors.New("no match found") // ErrEmptyPattern is returned when pattern is empty. ErrEmptyPattern = errors.New("empty pattern") )
View Source
var DefaultGrepOptions = GrepOptions{ IsRegexp: true, Before: 2, After: 2, }
Functions ¶
This section is empty.
Types ¶
type GrepOptions ¶
GrepOptions represents grep options. If IsRegexp is true, the pattern is treated as a regular expression. Before and After are the number of lines before and after the matched line.
type Match ¶
Match contains a matching line and its surrounding text.
func Grep ¶
func Grep(dat []byte, pattern string, opts GrepOptions) ([]*Match, error)
Grep reads data and returns lines that match the given pattern. If opts is nil, default options will be used.
func GrepWithCount ¶
GrepWithCount reads data and returns matching snippets and the total match count.
type WindowResult ¶
WindowResult contains a bounded snippet window and its continuation state.
func GrepWindow ¶
func GrepWindow(dat []byte, pattern string, opts GrepOptions) (*WindowResult, error)
GrepWindow returns at most opts.Limit snippets after opts.Offset matches. It stops once it can determine whether a continuation page exists.
Click to show internal directories.
Click to hide internal directories.