hpcloud / tail

Go package for reading from continously updated files (tail -f)
MIT License
2.7k stars 502 forks source link

Does this library support tailling multiple files? #172

Closed ruixue8080 closed 4 years ago

ruixue8080 commented 4 years ago

I tried two methods, neither not work. It seems that this library can only support tail -f one file, it is true? Here is the way I tried: method 1: func main() { t, _ := tail.TailFile("/home/ruixue/controller-binary/file1.log", tail.Config{Follow: true}) for line := range t.Lines { fmt.Println(line.Text) }

t2, _ := tail.TailFile("/home/ruixue/controller-binary/file2.log", tail.Config{Follow: true})
for line := range t2.Lines {
    fmt.Println(line.Text)
}

} method 2: `func main() { go tailFile1() go tailFile2() }

func tailFile1() { t, _ := tail.TailFile("/home/ruixue/controller-binary/file1.log", tail.Config{Follow: true}) for line := range t.Lines { fmt.Println(line.Text) } }

func tailFile2() { t2, _ := tail.TailFile("/home/ruixue/controller-binary/file2.log", tail.Config{Follow: true}) for line := range t2.Lines { fmt.Println(line.Text) } }`