(countersPath string)
| 300 | } |
| 301 | |
| 302 | func parseCounters(countersPath string) (map[string]CounterStats, error) { |
| 303 | entries, err := os.ReadDir(countersPath) |
| 304 | if err != nil { |
| 305 | if os.IsNotExist(err) { |
| 306 | return nil, nil |
| 307 | } |
| 308 | return nil, err |
| 309 | } |
| 310 | |
| 311 | stats := make(map[string]CounterStats, len(entries)) |
| 312 | for _, entry := range entries { |
| 313 | if entry.IsDir() { |
| 314 | continue |
| 315 | } |
| 316 | counterPath := filepath.Join(countersPath, entry.Name()) |
| 317 | counter, err := parseCounterFile(counterPath) |
| 318 | if err != nil { |
| 319 | return nil, err |
| 320 | } |
| 321 | stats[entry.Name()] = counter |
| 322 | } |
| 323 | |
| 324 | return stats, nil |
| 325 | } |
| 326 | |
| 327 | func parseCounterFile(path string) (CounterStats, error) { |
| 328 | file, err := openIfExists(path) |
no test coverage detected