Windows watch isnotexist file, then create it and write some text, but can't print the text
xkeyideal opened this issue · 1 comments
xkeyideal commented
Windows OS, go 1.7.4
cfg := tail.Config{ReOpen: true, MustExist: false, Follow: true}
t, err := tail.TailFile("D:\log\hotelprice\server\hotelprice_log4.log", cfg)
if err != nil {
fmt.Println(err)
}
for line := range t.Lines {
fmt.Println(line.Text)
}
the hotelprice_log4.log file is not exist.
- create the file hotelprice_log4.log
- open the file, then write contents, close it
but the program can't print the contents
dvas0004 commented
In windows the default inotify doesn't work too well... try using polling instead:
cfg := tail.Config{ReOpen: true, MustExist: false, Follow: true, Poll: true}
Does that help at all?