https://github.com/sagernet/fswatch
A simple fsnotify wrapper to watch file updates correctly
https://github.com/sagernet/fswatch
Last synced: 12 months ago
JSON representation
A simple fsnotify wrapper to watch file updates correctly
- Host: GitHub
- URL: https://github.com/sagernet/fswatch
- Owner: SagerNet
- License: other
- Created: 2024-06-25T15:19:27.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-26T02:58:54.000Z (almost 2 years ago)
- Last Synced: 2025-04-07T07:28:09.067Z (about 1 year ago)
- Language: Go
- Size: 5.86 KB
- Stars: 5
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# fswatch


[](https://pkg.go.dev/github.com/sagernet/fswatch)
fswatch is a simple [fsnotify] wrapper to watch file updates correctly.
[fsnotify]: https://github.com/fsnotify/fsnotify
Install
---
```bash
go get github.com/sagernet/fswatch
```
Example
---
```go
package main
import (
"log"
"github.com/sagernet/fswatch"
)
func main() {
var watchPath []string
watchPath = append(watchPath, "/tmp/my_file")
watcher, err := fswatch.NewWatcher(fswatch.Options{
Path: watchPath,
Callback: func(path string) {
log.Println("file updated: ", path)
},
})
if err != nil {
log.Fatal(err)
}
defer watcher.Close()
// Block main goroutine forever.
<-make(chan struct{})
}
```