code: func makeExclusionFilter(startDir string, patterns []string) (fs.ScanFilter, error) {
  	if len(patterns) == 0 {
  		return nil, nil
  	}
  
  	// Compile regular expressions.
  	exps := []*regexp.Regexp{}
  	for _, expr := range patterns {
  		if expr == "" {
  			continue
  		}
  		if expr[0] != '^' {
  			expr = "^" + expr
  		}
  		if expr[len(expr)-1] != '$' {
  			expr = expr + "$"
  		}
  		re, err := regexp.Compile(expr)
  		if err != nil {
  			return nil, err
  		}
  		exps = append(exps, re)
  	}
  
  	return func(abs string) bool {
  		rel, err := filepath.Rel(startDir, abs)
  		if err != nil {
  			return true
  		}
  		// Do not evaluate paths outside of startDir or startDir itself.
  		rel = filepath.ToSlash(rel)
  		if rel == "." || strings.HasPrefix(rel, "../") {
  			return false
  		}
  		for _, exp := range exps {
  			if exp.MatchString(rel) {
  				return true
  			}
  		}
  		return false
  	}, nil
  }
docs: // makeExclusionFilter produces a predicate that checks an absolute file path
  // against a list of regexps.
  //
  // Regexps are defined against slash separated paths relative to 'startDir'.
  // The predicate takes absolute native path, converts it to slash separated path
  // relative to 'startDir' and checks against list of regexps in 'patterns'.
  // Returns true to exclude a path.