github.com/dayvar14/tail@v0.0.0-20240222011302-f530c4fa0c9f/examples/01-tailAndPrint/main.go (about) 1 // Tail a file and print its contents. 2 // 3 // In this example you can add lines to the syslog log by using the logger 4 // command. Exit with Ctrl+C. 5 package main 6 7 import ( 8 "fmt" 9 10 "github.com/nxadm/tail" 11 ) 12 13 var logFile = "/var/log/syslog" 14 15 func main() { 16 t, err := tail.TailFile(logFile, tail.Config{Follow: true}) 17 if err != nil { 18 panic(err) 19 } 20 21 for line := range t.Lines { 22 fmt.Println(line.Text) 23 } 24 }