tail

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: MIT Imports: 11 Imported by: 2

README

Test Go Reference

go-tail

go-tail is an implementation of tail -F

tail, err = tail.NewTailFile("something.log")
for {
  select {
  case line := <- tail.Lines:
    log.Print(line.Text)
  case err := <- tail.Errors:
    log.Print(err)
  }
}

SEE ALSO

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Line

type Line struct {
	Text string
	Time time.Time
}

Line is a line of the target file.

type Options added in v1.0.0

type Options struct {
	// MaxBytesLine is maximum length of lines in bytes.
	// If it is zero, there is no limit.
	MaxBytesLine int64
}

Options is options for Tail

type Tail

type Tail struct {
	Lines  <-chan *Line
	Errors <-chan error
	// contains filtered or unexported fields
}

Tail tails a file.

func NewTailFile

func NewTailFile(filename string) (*Tail, error)

NewTailFile starts tailing a file with the default configuration.

func NewTailFileWithOptions added in v1.0.0

func NewTailFileWithOptions(filename string, opts Options) (*Tail, error)

NewTailFile starts tailing a file with opt options.

func NewTailReader

func NewTailReader(reader io.Reader) (*Tail, error)

NewTailReader starts tailing io.Reader with the default configuration.

func NewTailReaderWithOptions added in v1.0.0

func NewTailReaderWithOptions(reader io.Reader, opts Options) (*Tail, error)

NewTailReader starts tailing io.Reader

func (*Tail) Close

func (t *Tail) Close() error

Close stops tailing the file.

Jump to

Keyboard shortcuts

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