Files
safer-eve/playground/2-file-tail/tail.go
T
2019-12-16 21:39:57 +00:00

24 lines
314 B
Go

package main
import (
"fmt"
"github.com/hpcloud/tail"
)
func main() {
// https://godoc.org/github.com/hpcloud/tail#Config
t, err := tail.TailFile(
"/var/log/nginx.log",
tail.Config{
Follow: true,
})
if err != nil {
fmt.Println(err)
}
for line := range t.Lines {
fmt.Println(line.Text)
}
}