func main() { api := new(go140.API) authorize(api) file := path.Join(os.Getenv("HOME"), ".plan") in_args := inotify.IN_CLOSE_WRITE watcher, err := inotify.NewWatcher() if err != nil { log.Fatal(err) } err = watcher.AddWatch(os.Getenv("HOME"), in_args) if err != nil { log.Fatal(err) } for { select { case ev := <-watcher.Event: if ev.Mask == inotify.IN_CLOSE_WRITE || ev.Mask == inotify.IN_CREATE { if ev.Name == file { log.Println("Updating.") update(file, api) } } case err := <-watcher.Error: log.Println("error:", err) } } }
func NewInotifyWatcher() (*InotifyWatcher, os.Error) { inw := new(InotifyWatcher) inw.watchHandlers = make([]watchHandler, 0) var err os.Error inw.watcher, err = inotify.NewWatcher() if err != nil { return nil, err } return inw, nil }
func NewLparse() (*Lparse, os.Error) { parser := new(Lparse) watch, e := inotify.NewWatcher() if e != nil { return nil, e } server, e := StartServer(8080) if e != nil { return nil, e } parser.Watcher = watch parser.Storage = NewStorageController() parser.Server = server mainParser = parser return parser, nil }