github.com/icza/backscanner (go): Package backscanner provides a scanner similar to bufio.Scanner, but it reads and returns lines in reverse order, starting at a given position (which may be the end of the input) and going backward.  Unlike with bufio.Scanner, max line length may be configured.  Advancing and accessing lines of the input is done by calling Scanner.Line(), which returns the next line (previous in the source) as a string.  For maximum efficiency there is Scanner.LineBytes(). It returns the next line as a byte slice, which shares its backing array with the internal buffer of Scanner. This is because no copy is made from the line data; but this also means you can only inspect or search in the slice before calling Line() or LineBytes() again, as the content of the internal buffer–and thus slices returned by LineBytes()–may be overwritten. If you need to retain the line data, make a copy of it or use Line().  Example using it:  Output:  Using it to efficiently scan a file, finding last occurrence of a string ("error"):
Keywords: log|reverse|scanner