| 1 | # fswatch |
| 2 | ## go library for simple UNIX file system watching |
| 3 | |
| 4 | fswatch provides simple UNIX file system watching in Go. It is based around |
| 5 | the Watcher struct, which should be initialised with either NewWatcher or |
| 6 | NewAutoWatcher. Both functions accept a variable number of string arguments |
| 7 | specfying the paths to be loaded, which may be globbed, and return a pointer |
| 8 | to a Watcher. This value can be started and stopped with the Start() and |
| 9 | Stop() methods. The Watcher will automatically stop if all the files it is |
| 10 | watching have been deleted. |
| 11 | |
| 12 | The Start() method returns a read-only channel that receives Notification |
| 13 | values. The Stop() method closes the channel, and no files will be watched |
| 14 | from that point. |
| 15 | |
| 16 | The list of files being watched may be retrieved with the Watch() method and |
| 17 | the current state of the files being watched may be retrieved with the |
| 18 | State() method. See the go docs for more information. |
| 19 | |
| 20 | In synchronous mode (i.e. Watchers obtained from NewWatcher()), deleted files |
| 21 | will not be removed from the watch list, allowing the user to watch for files |
| 22 | that might be created at a future time, or to allow notification of files that |
| 23 | are deleted and then recreated. The auto-watching mode (i.e. from |
| 24 | NewAutoWatcher()) will remove deleted files from the watch list, as it |
| 25 | automatically adds new files to the watch list. |
| 26 | |
| 27 | ## Usage |
| 28 | There are two types of Watchers: |
| 29 | |
| 30 | * static watchers watch a limited set of files; they do not purge deleted |
| 31 | files from the watch list. |
| 32 | * auto watchers watch a set of files and directories; directories are |
| 33 | watched for new files. New files are automatically added, and deleted |
| 34 | files are removed from the watch list. |
| 35 | |
| 36 | Take a look at the provided `clinotify/clinotify.go` for an example; the |
| 37 | package is also well-documented. See the godocs for more specifics. |
| 38 | |
| 39 | ## License |
| 40 | |
| 41 | `fswatch` is licensed under the ISC license. |