/tail

Primary LanguageGo

Tail

GitHub Release Go Reference go.mod Build Status Go Report Card Codecov

A go module/package to read all lines appended to a file at runtime. It support file rotation which is a common practice for log files. It currently works on Linux and MacOS, not on Windows.

import "github.com/chmike/tail"

func main() {
  tail := NewTail("/var/log/auth.log")
  for {
    select {
      case line := <-tail.Line:
        println(line)
      case err := <-tail.Error:
        print("error:")
        println(err.Error())
        break
    }
  }
}