tail
tail copied to clipboard
Add SyncOpen config option
This new option allows the client to avoid the following race condition:
- open file "example.txt"
- StartTail("example.txt", Location: &SeekInfo(0, io.SeekEnd))
- append "hello\n" to example.txt
Without SyncOpen, this sequence may or may not see the line "hello" depending on a race between the goroutine that writes it and the goroutine that Tail runs.
With SyncOpen, the StartTail function doesn't return until the requested seek operation has been performed (unless the file doesn't exist, in which case no seek operation is performed, ensuring position 0 will be used when the file is created), so any writes performed after StartTail are guaranteed to be seen by the tail operation.
Addresses issue https://github.com/nxadm/tail/issues/49