2

Just like the command tail -f <a growing file> ?

whenever I read a growing file, it always encounter the EOF error, and then quit.

kostix
  • 51,517
  • 14
  • 93
  • 176
Coaku
  • 977
  • 1
  • 9
  • 23
  • 1
    I wound just delegate this task to `tail`, and [here's why](http://stackoverflow.com/a/8272924/720999). In short, reading an ever-growing file is a more complicated task that it appears on the first sight — take a look at how `tail` is implemented. – kostix Oct 16 '13 at 16:31
  • 3
    possible duplicate of [Reading log files as they're updated in Go](http://stackoverflow.com/questions/10135738/reading-log-files-as-theyre-updated-in-go) – nemo Oct 16 '13 at 18:41

2 Answers2

6

I haven't experimented with it much, but there is a github repository that aims to emulate tail functionality in Go: https://github.com/ActiveState/tail

Verran
  • 3,942
  • 2
  • 14
  • 22
  • For my uses that tail package have worked very nicely. It is a nice API and not a lot of code so easy to work with if it doesn't do exactly what you need. – Ask Bjørn Hansen Oct 17 '13 at 08:33
0

Find the answer as if you're programming in C on Linux, then use the same/analogous options to the equivalent 'open' system call.

brak2718
  • 84
  • 4