func (sm *ScanManager) IsActive(name string) bool {
	_, ok := sm.Scanners[name]
	if !ok {
		return false
	}
	return sm.intervals[name] != 0
}
IsActive returns true if a scanner exists and is active.
package main
import (
	"bufio"
	"bytes"
	"fmt"
	"log"
	"os"
	"os/exec"
	"sort"
	"strings"
	"sync"
	"time"
	"github.com/deanishe/awgo/util"
	"github.com/gobwas/glob"
)
var (
	scanners = map[string]Scanner{
		"find":   &findScanner{},
		"mdfind": &mdfindScanner{},
		"locate": &locateScanner{},
	}
)
type Scanner interface {
	Name() string                              
	Scan(conf *config) (<-chan string, error)  
}
type ScanManager struct {
	conf      *config
	Scanners  map[string]Scanner
	intervals map[string]time.Duration
}
func NewScanManager(conf *config) *ScanManager {
	sm := &ScanManager{
		conf:      conf,
		Scanners:  map[string]Scanner{},
		intervals: map[string]time.Duration{},
	}
	for name, sc := range scanners {
		var d time.Duration
		switch name {
		case "mdfind":
			d = conf.MDFindInterval
		case "locate":
			d = conf.LocateInterval
		case "find":
			d = conf.FindInterval
		default:
			log.Printf("[scan] unknown scanner: %s", name)
			d = conf.FindInterval
		}
		sm.Scanners[name] = sc
		sm.intervals[name] = d
	}
	return sm
}
func (sm *ScanManager) ScanDue() bool {
	if !wf.Cache.Exists(cacheKey) {
		return true
	}
	if len(sm.dueScanners()) > 0 {
		log.Printf("[scan] cache expired")
		return true
	}
	return false
}
func (sm *ScanManager) Scan() error {
	var (
		due   = map[string]bool{}
		ins   []<-chan string
		out   <-chan Project
		projs []Project
		f     = &Filter{}
	)
	for _, name := range sm.dueScanners() {
		due[name] = true
	}
	for name := range sm.Scanners {
		if !sm.IsActive(name) {
			if err := wf.Cache.Store(sm.cacheName(name), nil); err != nil {
				log.Printf("[scan] error clearing cache: %s", err)
			}
			log.Printf("[%s] inactive", name)
			continue
		}
		if due[name] {
			sc := sm.Scanners[name]
			if c, err := sc.Scan(sm.conf); err == nil {
				log.Printf("[%s] reloading ...", name)
				ins = append(ins, cacheProjects(sm.cacheName(name), c))
			} else {
				log.Printf("[%s] error: %v", name, err)
			}
		} else {
			log.Printf("[%s] loading from cache ...", name)
			ins = append(ins, sm.scanFromCache(name))
		}
	}
	f.Use(makeFilterExcludes(conf.Excludes))
	f.Use(filterNotExist)
	f.Use(filterDupes)
	f.Use(filterNotProject)
	out = resultToProject(f.Apply(merge(ins...)))
	for proj := range out {
		log.Printf("[scan] project: %s (%s)", proj.Name(), util.PrettyPath(proj.Path))
		projs = append(projs, proj)
	}
	log.Printf("%d total project(s) found", len(projs))
	return wf.Cache.StoreJSON(cacheKey, projs)
}