type Line struct { Text string Time time.Time Err error // Error from tail }
配置信息结构体为Config,用于指定文件被tail的方式:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
// Config is used to specify how a file must be tailed. type Config struct { // File-specifc Location *SeekInfo // Seek to this location before tailing ReOpen bool// Reopen recreated files (tail -F) MustExist bool// Fail early if the file does not exist Poll bool// Poll for file changes instead of using inotify Pipe bool// Is a named pipe (mkfifo) RateLimiter *ratelimiter.LeakyBucket
// Generic IO Follow bool// Continue looking for new lines (tail -f) MaxLineSize int// If non-zero, split longer lines into multiple lines
// Logger, when nil, is set to tail.DefaultLogger // To disable logging: set field to tail.DiscardingLogger Logger logger }