hpcloud / tail

Go package for reading from continously updated files (tail -f)
MIT License
2.7k stars 502 forks source link

Export EOF detection #160

Closed sunshine69 closed 4 years ago

sunshine69 commented 4 years ago

Hi,

In my code I need to detect EOF to do some decisions (basically flush the line stack in multiline parser). However tail does not export the file handle file thus I have to write my own short func to use os.Open the file, seek to the position where tail.Tell() is and try to read one byte to see if I got error is EOF.

This is not efficient I think. In my opinion there should be a better way tail package can export the state for us. Or at least export the file handle so I don't have to call one system os.Open again.

Any ideas to solve it? Or I am missing the doco and not using it right.

Thanks for excellent work and Kind regards

nxadm commented 4 years ago

I don't know if this is useful to you, but I merged a PR that exposes SeekInfo information:

https://github.com/nxadm/tail/blob/master/tail.go#L31

Because this repo seems to be dormant for more than a year, I forked it and added the PRs that needed to be merged.

sunshine69 commented 4 years ago

Hi thanks for suggestion but it seems not be useful. The SeekInfo only gives me pos and whence but no way to see if it is an EOF.

however good to know that your repo has better maintained than this.