()
| 81 | } |
| 82 | |
| 83 | func main() { |
| 84 | flag.Parse() |
| 85 | |
| 86 | // For debugging purposes, processing just a single or a few files is helpful: |
| 87 | var processOnly map[string]bool |
| 88 | if *verbose { // Only create the map if args are provided. |
| 89 | for _, arg := range flag.Args() { |
| 90 | if processOnly == nil { |
| 91 | processOnly = map[string]bool{} |
| 92 | } |
| 93 | processOnly[arg] = true |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | fset := token.NewFileSet() |
| 98 | |
| 99 | pkgs, err := parser.ParseDir(fset, ".", sourceFilter, 0) |
| 100 | if err != nil { |
| 101 | log.Fatal(err) |
| 102 | return |
| 103 | } |
| 104 | |
| 105 | for pkgName, pkg := range pkgs { |
| 106 | t := &templateData{ |
| 107 | filename: pkgName + fileSuffix, |
| 108 | Year: 2017, |
| 109 | Package: pkgName, |
| 110 | Imports: map[string]string{}, |
| 111 | } |
| 112 | for filename, f := range pkg.Files { |
| 113 | if *verbose && processOnly != nil && !processOnly[filename] { |
| 114 | continue |
| 115 | } |
| 116 | |
| 117 | logf("Processing %v...", filename) |
| 118 | if err := t.processAST(f); err != nil { |
| 119 | log.Fatal(err) |
| 120 | } |
| 121 | } |
| 122 | if err := t.dump(); err != nil { |
| 123 | log.Fatal(err) |
| 124 | } |
| 125 | } |
| 126 | logf("Done.") |
| 127 | } |
| 128 | |
| 129 | func (t *templateData) processAST(f *ast.File) error { |
| 130 | for _, decl := range f.Decls { |
nothing calls this directly
no test coverage detected
searching dependent graphs…