You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.5 KiB

  1. ![ci](https://github.com/nxadm/tail/workflows/ci/badge.svg)[![Go Reference](https://pkg.go.dev/badge/github.com/nxadm/tail.svg)](https://pkg.go.dev/github.com/nxadm/tail)
  2. # tail functionality in Go
  3. nxadm/tail provides a Go library that emulates the features of the BSD `tail`
  4. program. The library comes with full support for truncation/move detection as
  5. it is designed to work with log rotation tools. The library works on all
  6. operating systems supported by Go, including POSIX systems like Linux and
  7. *BSD, and MS Windows. Go 1.9 is the oldest compiler release supported.
  8. A simple example:
  9. ```Go
  10. // Create a tail
  11. t, err := tail.TailFile(
  12. "/var/log/nginx.log", tail.Config{Follow: true, ReOpen: true})
  13. if err != nil {
  14. panic(err)
  15. }
  16. // Print the text of each received line
  17. for line := range t.Lines {
  18. fmt.Println(line.Text)
  19. }
  20. ```
  21. See [API documentation](https://pkg.go.dev/github.com/nxadm/tail).
  22. ## Installing
  23. go get github.com/nxadm/tail/...
  24. ## History
  25. This project is an active, drop-in replacement for the
  26. [abandoned](https://en.wikipedia.org/wiki/HPE_Helion) Go tail library at
  27. [hpcloud](https://github.com/hpcloud/tail). Next to
  28. [addressing open issues/PRs of the original project](https://github.com/nxadm/tail/issues/6),
  29. nxadm/tail continues the development by keeping up to date with the Go toolchain
  30. (e.g. go modules) and dependencies, completing the documentation, adding features
  31. and fixing bugs.
  32. ## Examples
  33. Examples, e.g. used to debug an issue, are kept in the [examples directory](/examples).