func New(opt ...Option) *Watcher {
	o := &options{}
	for _, v := range opt {
		v(o)
	}
	if o.notify == nil {
		panic("notify can not be nil")
	}
	if o.logger == nil {
		o.logger = log.Println
	}
	res := &Watcher{
		add:     make(chan fspath),
		paths:   make(map[string]bool),
		notify:  o.notify,
		exclude: o.exclude,
		logger:  o.logger,
	}
	res.ctx, res.cancel = context.WithCancel(context.Background())
	res.start()
	return res
}
New creates a new *Watcher. Excluded patterns are based on
filepath.Match function patterns.
package dirwatch
import (
	"context"
	"fmt"
	"log"
	"os"
	"path/filepath"
	"time"
	"github.com/dc0d/retry"
	"github.com/fsnotify/fsnotify"
	"github.com/pkg/errors"
)
type Event struct {
	Name string
	Op   fsnotify.Op
}
type options struct {
	notify  func(Event)
	exclude []string
	logger  func(args ...interface{})
}
type Option func(*options)
func Notify(notify func(Event)) Option {
	return func(opt *options) {
		opt.notify = notify
	}
}
func Exclude(exclude ...string) Option {
	return func(opt *options) {
		opt.exclude = exclude
	}
}
func Logger(logger func(args ...interface{})) Option {
	return func(opt *options) {
		opt.logger = logger
	}
}
type Watcher struct {
	notify  func(Event)
	exclude []string
	logger  func(args ...interface{})
	paths  map[string]bool
	add    chan fspath
	ctx    context.Context
	cancel context.CancelFunc
}
type fspath struct {
	path      string
	recursive *bool
}