Skip to content

Instantly share code, notes, and snippets.

@pablodz
Created January 13, 2023 11:41
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save pablodz/e72fb4f1c5fd05d12d2182eb0668eccd to your computer and use it in GitHub Desktop.
package example
import "github.com/pablodz/inotifywaitgo/inotifywaitgo"
func Example() {
dir := "./my_files"
files := make(chan []byte)
errors := make(chan []byte)
go inotifywaitgo.WatchPath(&inotifywaitgo.Settings{
Dir: dir,
OutFiles: files,
ErrorChan: errors,
Options: &inotifywaitgo.OptionsInotify{
Recursive: true,
Events: []string{inotifywaitgo.EventCloseWrite},
Monitor: true,
},
Verbose: true,
})
loopFiles:
for {
select {
case file := <-files:
println(string(file))
case err := <-errors:
println(string(err))
break loopFiles
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment