-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tailer: add option to start tailing at specified seek offset #47
base: master
Are you sure you want to change the base?
Conversation
It would be nice to have a |
I don't have any idea why the Windows integration test is failing, I think the behavior introduced by this patch should be the same, and the go tests pass. Do the integration tests depend on the go tests somehow? |
cf67c51
to
694910a
Compare
The tests sometimes fail on travis-ci or appveyor. This has nothing to do with your pr. It seems to be a timing issue, but I can't reproduce it locally. Restarted the Windows build and it succeeded. |
I think it's a good idea to make the tailer useful as a library for other applications than |
The usecase I have in mind is similar to Now, because my patch doesn't give an option to go back N lines, this implementation requires the caller to either know a particular offset they want to seek to, or make some kind of guess about how far from the end they want to see. However, either of these are better than reading the entire file from disk. |
As you said, the main usage would be to skip a number of lines (like It would be great to provide a One way to implement that would be to add the following method to func (file *File) SeekLines(nLines int, whence int) {
// ...
} I think it would be worthwhile to add that. |
Yes, it would be great to provide an API that does that. However, it's not something I need at the moment (as I'm storing offsets), and it seems like a lot of work. In theory one could just translate the tail implementation into go... but that version of tail I linked above is GPL3 so that could be problematic. The BSD version is available at https://github.com/freebsd/freebsd/blob/master/usr.bin/tail/read.c#L137 Also, I think it would be useful to have an offset-based API in addition to a line-based API. I guess yet another function could be added for that? |
I can implement a |
d53e0a7
to
ad188fd
Compare
b661e7b
to
09fa4c4
Compare
50bbec7
to
801df77
Compare
There could be a better way to construct this, but seems good enough for now.