Package Usage: go: github.com/kgoins/backscanner
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"):
2 versions
Latest release: over 3 years ago
1 dependent package
View more package details: https://packages.ecosyste.ms/registries/proxy.golang.org/packages/github.com/kgoins/backscanner
View more repository details: http://repos.ecosyste.ms/hosts/GitHub/repositories/kgoins%2Fbackscanner
Dependent Repos 1
kgoins/ldifparser
An LDIF reader/writerSize: 1020 KB - Last synced: 11 months ago - Pushed: over 2 years ago
