Skip to content

Instantly share code, notes, and snippets.

@syossan27
Created September 24, 2017 10:54
Show Gist options
  • Select an option

  • Save syossan27/be8a1e9dfa25c74a064fbf137c293b0e to your computer and use it in GitHub Desktop.

Select an option

Save syossan27/be8a1e9dfa25c74a064fbf137c293b0e to your computer and use it in GitHub Desktop.
// NewWatcher establishes a new watcher with the underlying OS and begins waiting for events.
func NewWatcher() (*Watcher, error) {
kq, err := kqueue()
if err != nil {
return nil, err
}
w := &Watcher{
kq: kq,
watches: make(map[string]int),
dirFlags: make(map[string]uint32),
paths: make(map[int]pathInfo),
fileExists: make(map[string]bool),
externalWatches: make(map[string]bool),
Events: make(chan Event),
Errors: make(chan error),
done: make(chan bool),
}
go w.readEvents()
return w, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment