Skip to content

sandovalrr/gowatcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Watcher

Light go library to watch directory files

Instalation

$ go get github.com/sandovalrr/gowatcher

or using glide

$ glide get github.com/sandovalrr/gowatcher

Usage

import (

  "time"

  "github.com/fsnotify/fsnotify"

  "github.com/sandovalrr/gowatcher"
)

//...
//...

watcher := gowatcher.NewWatcher(gowatcher.WatcherOption{
  Dirs: []string{"test_path_to_watch","another_path_to_watch"},
  Recursive: true,
  Extensions: []string{".mp3",".wav"},
})

go watcher.Start()

subscriber := &gowatcher.Emitter{
  Channel: make(chan string),
  Wait:    time.Duration(0),
}

watcher.Subscribe(fsnotify.Create, subscriber)

//...
go func(subscriber *gowatcher.Emitter){
  for {
    select {
      case path := <- subscriber.Channel:
      //Action on event
    }
  }
}(subscriber)
//...

//onFinish
watcher.Close()

API

About

Light go library to watch directory files

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages