(fs fs.Filesystem, opts ...Option)
| 151 | } |
| 152 | |
| 153 | func New(fs fs.Filesystem, opts ...Option) *Matcher { |
| 154 | m := &Matcher{ |
| 155 | fs: fs, |
| 156 | stop: make(chan struct{}), |
| 157 | } |
| 158 | for _, opt := range opts { |
| 159 | opt(m) |
| 160 | } |
| 161 | if m.changeDetector == nil { |
| 162 | m.changeDetector = newModtimeChecker() |
| 163 | } |
| 164 | if m.withCache { |
| 165 | go m.clean(2 * time.Hour) |
| 166 | } |
| 167 | return m |
| 168 | } |
| 169 | |
| 170 | // Load and parse a file. The returned error may be of type *ParseError in |
| 171 | // which case a file was loaded from disk but the patterns could not be |