github.com/netdata/go.d.plugin@v0.58.1/modules/filecheck/collect.go (about)

     1  // SPDX-License-Identifier: GPL-3.0-or-later
     2  
     3  package filecheck
     4  
     5  import (
     6  	"regexp"
     7  	"runtime"
     8  	"strings"
     9  )
    10  
    11  func (fc *Filecheck) collect() (map[string]int64, error) {
    12  	ms := make(map[string]int64)
    13  
    14  	fc.collectFiles(ms)
    15  	fc.collectDirs(ms)
    16  
    17  	return ms, nil
    18  }
    19  
    20  func hasMeta(path string) bool {
    21  	magicChars := `*?[`
    22  	if runtime.GOOS != "windows" {
    23  		magicChars = `*?[\`
    24  	}
    25  	return strings.ContainsAny(path, magicChars)
    26  }
    27  
    28  func removeDuplicates(s []string) []string {
    29  	set := make(map[string]bool, len(s))
    30  	uniq := s[:0]
    31  	for _, v := range s {
    32  		if !set[v] {
    33  			set[v] = true
    34  			uniq = append(uniq, v)
    35  		}
    36  	}
    37  	return uniq
    38  }
    39  
    40  var reSpace = regexp.MustCompile(`\s`)