Watcher is a simple Go package for watching for file/directory changes

In the process of re-writing a small application, I’ve just extracted a small file/folder watcher which doesn’t rely on any file system events, so it should be cross platform no problem.

It’s very simple at the moment and there are probably dozens of other similar packages like this, but maybe this will be helpful to someone:

Lastly there is only one example, but no tests, so you’ll have to forgive me for not writing them yet :stuck_out_tongue:

1 Like

Update: Added 2 new options for when initializing a Watcher.

  1. watcher.NonRecursive, to stop the watcher from watching files and folders recursively.
  2. watcher.IgnoreDotFiles to stop the watcher from watching dotfiles.

Update 2:

  1. Customizable polling interval.
  2. Limit the amount of events that can be received per watching cycle.
  3. Trigger custom events.

Update 3: Added a simple watcher command that gets installed with the go get installation command. (Found here)

The command is useful for watching for events and running commands anytime an event occurs.

Update 4:

  1. Notify the full path of the file that the event is based on.
  2. Added rename Event which currently works at least on systems where mod time is unaffected by a file rename, for example on my MacBook Pro when using the mv command (will re-write for better compatibility)
  3. Added chmod Event.

@radovskyb, just to let you know that the goliv project I talked about a while ago is finally shaping up thanks to your watcher =]

1 Like

Hey @ericmdantas, that’s awesome!

I just added rename and chmod events to watcher and decided to change the event names to use simpler consts such as watcher.Add or watcher.Remove (kind of like fsnotify’s), just in case you re-download it and the current consts seem to not work :stuck_out_tongue:

Also thanks for your contributions to it as well… I had never even used travis ci until you added it to the readme and it’s really cool so thanks a lot for that =D

Anyway, if there’s any features you want to suggest for watcher just let me know anytime :smiley:

@radovskyb thanks for the heads up, just updated the project.

I’m glad you liked travis ci, it’s really handy for both small and big projects - pet projects or not.

I’ll let you know if there’s something we can implement, but as of right now, everything is pretty good. :thumbsup:

1 Like

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