Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/y-yagi/rnotify
`rnotify` is a wrapper of `fsnotify`, supports recursive directory watching on Go.
https://github.com/y-yagi/rnotify
go watch-files
Last synced: 24 days ago
JSON representation
`rnotify` is a wrapper of `fsnotify`, supports recursive directory watching on Go.
- Host: GitHub
- URL: https://github.com/y-yagi/rnotify
- Owner: y-yagi
- License: mit
- Created: 2020-12-26T05:19:17.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-14T06:53:34.000Z (over 2 years ago)
- Last Synced: 2024-10-04T18:26:27.290Z (about 1 month ago)
- Topics: go, watch-files
- Language: Go
- Homepage:
- Size: 22.5 KB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rnotify
![Build Status](https://github.com/y-yagi/rnotify/workflows/CI/badge.svg)
[![Go Reference](https://pkg.go.dev/badge/github.com/y-yagi/rnotify.svg)](https://pkg.go.dev/github.com/y-yagi/rnotify)`rnotify` is a wrapper of [fsnotify](https://github.com/fsnotify/fsnotify), supports recursive directory watching on Go.
## Supported Platforms
Linux, Windows and macOS.
## Usage
```go
package mainimport (
"log""github.com/fsnotify/fsnotify"
"github.com/y-yagi/rnotify"
)func main() {
watcher, err := rnotify.NewWatcher()
if err != nil {
log.Fatal(err)
}
defer watcher.Close()done := make(chan bool)
go func() {
for {
select {
case event, ok := <-watcher.Events:
if !ok {
return
}
log.Println("event:", event)
// `Op` is the same as `fsnotify.Op`.
if event.Op&fsnotify.Write == fsnotify.Write {
log.Println("modified file:", event.Name)
}
case err, ok := <-watcher.Errors:
if !ok {
return
}
log.Println("error:", err)
}
}
}()err = watcher.Add("/tmp/foo")
if err != nil {
log.Fatal(err)
}<-done
}```