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)
}
}`
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) }
} 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) } }`