Code Room
Code reviewMediumcr-g346
Subject Data bugsLevel Mid–Senior~16 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Go that computes per-cache hit-rate percentages for a dashboard tile.

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.

Talk through your review
Code to reviewgo
type CacheStats struct {    Name   string    Hits   int    Total  int} func hitRate(hits, total int) int {    if total == 0 {        return 0    }    return (hits / total) * 100} func tiles(stats []CacheStats) map[string]int {    out := map[string]int{}    for _, s := range stats {        out[s.Name] = hitRate(s.Hits, s.Total)  // e.g. 950/1000    }    return out}
Run or narrate your approach, then ask the coach.