Update scripts/metricsgen/metricsgen.go

Co-authored-by: M. J. Fromberger <fromberger@interchain.io>
This commit is contained in:
William Banfield
2022-05-09 16:59:02 -04:00
committed by GitHub
parent 0750b1f13e
commit 6469c0564c

View File

@@ -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 {