yttopodcast/cmd/watchfile/watchfile.go
HeshamTB 92dddc7ebe cmd: testing commands
Signed-off-by: HeshamTB <hishaminv@gmail.com>
2024-08-14 14:42:02 +03:00

36 lines
538 B
Go

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