(path string, apply func(summaryRecord))
| 183 | } |
| 184 | |
| 185 | func walkSessionFile(path string, apply func(summaryRecord)) error { |
| 186 | f, err := os.Open(path) |
| 187 | if err != nil { |
| 188 | return fmt.Errorf("open session %q: %w", path, err) |
| 189 | } |
| 190 | defer f.Close() |
| 191 | |
| 192 | reader := bufio.NewReader(f) |
| 193 | for { |
| 194 | line, readErr := reader.ReadBytes('\n') |
| 195 | if len(line) > 0 { |
| 196 | var rec summaryRecord |
| 197 | if err := json.Unmarshal(line, &rec); err == nil { |
| 198 | apply(rec) |
| 199 | } |
| 200 | } |
| 201 | if readErr == io.EOF { |
| 202 | return nil |
| 203 | } |
| 204 | if readErr != nil { |
| 205 | return fmt.Errorf("read session %q: %w", path, readErr) |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | func applyRecordToSummary(s *Summary, rec summaryRecord) { |
| 211 | ts := parseRecordTime(rec.Timestamp) |
no test coverage detected