Created
October 25, 2013 15:50
-
-
Save howeyc/7156865 to your computer and use it in GitHub Desktop.
Additional OptionsWatcher interface. Didn't actually attempt to use, just an idea.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type FileNotification interface { | |
IsCreate() bool | |
IsDelete() bool | |
IsModify() bool | |
IsRename() bool | |
Path() string // relative path to the file | |
} | |
type OptionWatcher interface { | |
Close() error | |
RemoveWatch(string) error | |
WatchPath(string, *Options) error | |
NextNotification() (FileNotification, error) | |
} | |
func NewOptionWatcher() (OptionWatcher, error) { | |
return NewWatcher() | |
} | |
func (w *Watcher) NextNotification() (fn FileNotification, err error) { | |
select { | |
case fn = <-w.internalEvent: | |
case err = <-w.Error: | |
} | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What would the calling code for Next() look like?
Lots of iterator options http://ewencp.org/blog/golang-iterators/