{"modulePath":"github.com/wavetermdev/waveterm","version":"v0.14.5","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package readutil\n\n## Constants\n\n```go\nconst (\n\tStopReasonBOF       = \"bof\"\n\tStopReasonEOF       = \"eof\"\n\tStopReasonReadLimit = \"read_limit\"\n)\n```\n\n## Functions\n\n```go\nfunc ReadLastNLineOffsets(rs io.ReadSeeker, maxLines int, keepFirst bool) ([]int64, int, error)\n```\nreadLastNLineOffsets 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.\n\n```go\nfunc ReadLines(reader io.Reader, lineCount int, skipLines int, readLimit int) ([]string, string, error)\n```\nReadLines 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).\n\n```go\nfunc ReadTailLines(file *os.File, lineCount int, lineOffset int, readLimit int64) ([]string, string, error)\n```\nReadTailLines 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).\n\n","path":"github.com/wavetermdev/waveterm/pkg/util/readutil","name":"readutil","synopsis":"","isRedistributable":true}
