Version: v20.10.11+incompatible Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2021 License: Apache-2.0 Imports: 6 Imported by: 47



Package tailfile provides helper functions to read the nth lines of any ReadSeeker.



This section is empty.


View Source
var ErrNonPositiveLinesNumber = errors.New("The number of lines to extract from the file must be positive")

ErrNonPositiveLinesNumber is an error returned if the lines number was negative.


func NewTailReader

func NewTailReader(ctx context.Context, r SizeReaderAt, reqLines int) (io.Reader, int, error)

NewTailReader scopes the passed in reader to just the last N lines passed in

func NewTailReaderWithDelimiter

func NewTailReaderWithDelimiter(ctx context.Context, r SizeReaderAt, reqLines int, delimiter []byte) (io.Reader, int, error)

NewTailReaderWithDelimiter scopes the passed in reader to just the last N lines passed in In this case a "line" is defined by the passed in delimiter.

Delimiter lengths should be generally small, no more than 12 bytes

func TailFile

func TailFile(f *os.File, n int) ([][]byte, error)

TailFile returns last n lines of the passed in file.


type SizeReaderAt

type SizeReaderAt interface {
	Size() int64

SizeReaderAt is an interface used to get a ReaderAt as well as the size of the underlying reader. Note that the size of the underlying reader should not change when using this interface.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL