Help us shape the future of Go! Take the 2026 Go Developer Survey

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: 0

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