Watcher rewrite and updates

A lot of Watcher has now been rewritten and now contains better/cleaner code.

API Changes

  • Instead of adding and removing directories recursively by default or passing options to specify to watch non-recursively, there are now 2 cleaner methods for each, Add + AddRecursive and Remove + RemoveRecursive.
  • There’s also no longer the need to choose whether to ignore hidden files or not as an option, as there’s a new IgnoreHiddenFiles method instead.
  • Rename and Move events now return the path (Event.Path) in the format of oldPath -> newPath.

New

  • Close method to stop the watcher, as well as clearing the watched file’s list.
  • Closed channel to listen for when the watcher is closed, used to break out of the main polling goroutine loop, preventing any goroutine leaks.
  • Added Move Event.
  • Event filtering to specify what events to receive on the Event channel. For example, choosing only to receive Rename or Move events.
4 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.