yttopodcast/cmd/watchfile/watchfile.go

36 lines
538 B
Go
Raw Normal View History

package main
import (
"fmt"
"log"
"github.com/gohugoio/hugo/watcher/filenotify"
)
func main() {
w, err := filenotify.NewEventWatcher()
if err != nil {
log.Fatalln(err.Error())
}
defer w.Close()
err = w.Add("test")
if err != nil {
log.Fatalln(err.Error())
}
for {
select {
case e, ok:= <- w.Events():
if !ok {
log.Println("channel closed")
return
}
fmt.Printf("e: %v\n", e)
}
}
}