in image/resources/filter-exports/filter.go [37:82]
func (f *filter) run() error {
// no filters, stream the input directly to the output
if len(f.excludes) == 0 && len(f.includes) == 0 {
_, err := io.Copy(f.output, f.input)
return err
}
s := bufio.NewScanner(f.input)
for s.Scan() {
line := s.Text()
if line == "" {
continue
}
export := line
if f.field > 0 {
var err error
export, err = extractField(line, f.field-1)
if err != nil {
return err
}
}
if !strings.HasSuffix(export, "/") {
export += "/"
}
if !match(export, f.includes, true) {
if *verbose {
fmt.Fprintf(os.Stderr, "Skipped \"%s\", did not match include filter", export)
}
continue
}
if match(export, f.excludes, false) {
if *verbose {
fmt.Fprintf(os.Stderr, "Skipped \"%s\", export was excluded", export)
}
continue
}
fmt.Fprintln(f.output, line)
}
return s.Err()
}