countFiles counts files ending in ext inside /*/ /.
(base, sub, ext string)
| 272 | |
| 273 | // countFiles counts files ending in ext inside <base>/*/<sub>/. |
| 274 | func countFiles(base, sub, ext string) int { |
| 275 | entries, err := os.ReadDir(base) |
| 276 | if err != nil { |
| 277 | return 0 |
| 278 | } |
| 279 | n := 0 |
| 280 | for _, e := range entries { |
| 281 | if !e.IsDir() { |
| 282 | continue |
| 283 | } |
| 284 | inner := filepath.Join(base, e.Name(), sub) |
| 285 | files, err := os.ReadDir(inner) |
| 286 | if err != nil { |
| 287 | continue |
| 288 | } |
| 289 | for _, f := range files { |
| 290 | if !f.IsDir() && strings.HasSuffix(f.Name(), ext) { |
| 291 | n++ |
| 292 | } |
| 293 | } |
| 294 | } |
| 295 | return n |
| 296 | } |
| 297 | |
| 298 | // countKBFacts counts entry lines (starting with "- ") across kb/*.md. |
| 299 | func countKBFacts(kbDir string) int { |