Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct { Hits int Lines []int Pattern string // contains filtered or unexported fields }
Result describes the results of a search
func NewSearch ¶
NewSearch searches in a multiline string for lines that match the given pattern, it returns: * the number of hits (lines) * the line index
func (*Result) InitialLine ¶
InitialLine sets the position for iterating the search results on the first line that is either has the same value or is the closest from 0 to the given line number. So, for a result that found that lines (1, 3, 5) were a hit: * InitialLine(-1) will set the internal iteration index at 0 (the default starting index) * InitialLine(3) will set the internal iteration index at 1. * InitialLine(4) will set the internal iteration index at 1. * InitialLine(10) will set the internal iteration index at 2.
func (*Result) NextLine ¶
NextLine returns the previous line while iterating the search results. So, for a result that found that lines (1, 3, 5) were a hit: *NextLine() should give 1 *NextLine() should give 3 *NextLine() should give 5 *NextLine() should give 5
func (*Result) PreviousLine ¶
PreviousLine returns the previous line while iterating the search results. So, for a result that found that lines (1, 3, 5) were a hit: * NextLine() should give 1 * NextLine() should give 3 * PreviousLine() should give 1 * PreviousLine() should give 1