diff --git a/scripts/metricsgen/metricsgen.go b/scripts/metricsgen/metricsgen.go index a63fdeb99..4b122f975 100644 --- a/scripts/metricsgen/metricsgen.go +++ b/scripts/metricsgen/metricsgen.go @@ -144,14 +144,14 @@ func main() { log.Fatalf("Generating code: %v", err) } } +func ignoreTestFiles(f fs.FileInfo) bool { + return !strings.Contains(f.Name(), "_test.go") +} // ParseMetricsDir parses the dir and scans for a struct matching structName, // ignoring all test files. ParseMetricsDir iterates the fields of the metrics // struct and builds a TemplateData using the data obtained from the abstract syntax tree. func ParseMetricsDir(dir string, structName string) (TemplateData, error) { - ignoreTestFiles := func(f fs.FileInfo) bool { - return !strings.Contains(f.Name(), "_test.go") - } fs := token.NewFileSet() d, err := parser.ParseDir(fs, dir, ignoreTestFiles, parser.ParseComments) if err != nil {