Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func Watch ¶
func Watch(eventMappers ...PathEventMapper) ssm.Fn
Example ¶
t := testing.T{} tempDir := filepath.Join(os.TempDir(), "test") defer func() { _ = os.RemoveAll(tempDir) }() mkdir(&t, tempDir) go func() { eventSeparator() touch(&t, filepath.Join(tempDir, "1")) }() printEventFn := func(out io.Writer) func(fsnotify.Event) ssm.Fn { return func(event fsnotify.Event) ssm.Fn { _, _ = fmt.Fprintf(out, "Event: %#v\n", event) return Stop } } ww := Watch(On(printEventFn(os.Stdout), tempDir)) ctx, cancel := context.WithTimeout(context.Background(), time.Second) defer cancel() err := ssm.Run(ctx, ww) fmt.Printf("Err: %v\n", err)
Output: Event: fsnotify.Event{Name:"/tmp/test/1", Op:0x1, renamedFrom:""} Err: stop
Types ¶
type PathEventMapper ¶
func On ¶
func On(fn EventFn, paths ...string) PathEventMapper
Click to show internal directories.
Click to hide internal directories.