lastnlines

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: GPL-3.0 Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

lastnlines

tail the last N lines of a watched file

func main() {
	ln := NewLNL("./test.txt")
	ln.SetDepth(10)
	ln.Start()
	iter := 0
	stop := false
	for {
		iter += 1
		fmt.Println(iter)
		for _, line := range ln.Get() {
			fmt.Println(line)
			if strings.Contains(line, "stop_watching") {
				ln.Stop()
				stop = true
			}
		}
		if stop {
			break
		}
		time.Sleep(3 * time.Second)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LastNLines

type LastNLines struct {
	// contains filtered or unexported fields
}

func NewLNL

func NewLNL(f string) *LastNLines

func (*LastNLines) Get

func (ll *LastNLines) Get() []string

func (*LastNLines) GetFILO

func (ll *LastNLines) GetFILO() []string

func (*LastNLines) GetLIFO

func (ll *LastNLines) GetLIFO() []string

func (*LastNLines) IsAlive

func (ll *LastNLines) IsAlive() bool

func (*LastNLines) LastItem

func (ll *LastNLines) LastItem() (string, error)

func (*LastNLines) SetDepth

func (ll *LastNLines) SetDepth(d int)

func (*LastNLines) Start

func (ll *LastNLines) Start()

func (*LastNLines) Stop

func (ll *LastNLines) Stop()

Jump to

Keyboard shortcuts

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