Interface{} boxing on hot path
Review this Go metrics aggregator on a hot path.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.
0:00 of about 22 min
Mark a line and say what kind of problem it is.0 findings
1func record(metrics map[string]interface{}, name string, v float64) {
2 metrics[name] = v // float64 boxed into interface{}
3}
4
5func total(metrics map[string]interface{}) float64 {
6 var sum float64
7 for _, raw := range metrics {
8 sum += raw.(float64) // type assertion per entry
9 }
10 return sum
11}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.
Run or narrate your approach, then ask the coach.