Skip to content

Instantly share code, notes, and snippets.

@vodrazka
Created May 5, 2016 20:59
Show Gist options
  • Save vodrazka/b36a58c20d6703b67ab1ff3c7412399f to your computer and use it in GitHub Desktop.
Save vodrazka/b36a58c20d6703b67ab1ff3c7412399f to your computer and use it in GitHub Desktop.
import (
"fmt"
"github.com/fane89/gotron/ecs"
"github.com/fane89/gotron/ecs/systems"
"log"
"github.com/howeyc/fsnotify"
)
func main() {
watcher, err := fsnotify.NewWatcher()
if err != nil {
log.Fatal(err)
}
done := make(chan bool)
// Process events
go func() {
for {
select {
case ev := <-watcher.Event:
log.Println("event:", ev)
case err := <-watcher.Error:
log.Println("error:", err)
}
}
}()
err = watcher.Watch("a")
if err != nil {
log.Fatal(err)
}
// Hang so program doesn't exit
<-done
/* ... do stuff ... */
watcher.Close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment