Documentation
¶
Index ¶
- Constants
- func ReadLastNLineOffsets(rs io.ReadSeeker, maxLines int, keepFirst bool) ([]int64, int, error)
- func ReadLines(reader io.Reader, lineCount int, skipLines int, readLimit int) ([]string, string, error)
- func ReadTailLines(file *os.File, lineCount int, lineOffset int, readLimit int64) ([]string, string, error)
Constants ¶
const ( StopReasonBOF = "bof" StopReasonEOF = "eof" StopReasonReadLimit = "read_limit" )
Variables ¶
This section is empty.
Functions ¶
func ReadLastNLineOffsets ¶
readLastNLineOffsets reads all line offsets from the reader, keeping only the last maxLines in a sliding window. keepFirst indicates whether offset 0 should be included (true if starting from file beginning). Returns the offsets and the total number of lines found.
func ReadLines ¶
func ReadLines(reader io.Reader, lineCount int, skipLines int, readLimit int) ([]string, string, error)
ReadLines reads lines from the reader, optionally skipping the first skipLines lines. If lineCount is 0, no line limit is applied. If readLimit is 0, no byte limit is applied. Stops when either limit is reached or EOF. Returns lines (with trailing newlines), stop reason, and error. Stop reason is StopReasonEOF when EOF is reached, StopReasonReadLimit when byte limit is reached, or empty string for natural returns (line count limit or no limits applied).
func ReadTailLines ¶
func ReadTailLines(file *os.File, lineCount int, lineOffset int, readLimit int64) ([]string, string, error)
ReadTailLines reads the last lineCount lines from a file, excluding the last lineOffset lines. It progressively reads larger windows from the end of the file (starting at 1MB, doubling up to readLimit) until it finds enough lines or reaches the limit. Returns the lines, stop reason, and any error. Stop reason is StopReasonBOF when beginning of file is reached, StopReasonReadLimit when byte limit is reached, or empty string for natural completion (found requested line count).
Types ¶
This section is empty.