Code Room
Code reviewMediumcr-g576
Subject Concurrency data raceLevel Mid–Senior~25 minCommon in Concurrency interviewsIndustries Software development, Technology

Question

Review this Go HTTP handler that counts requests per endpoint.

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
var hits = map[string]int{} func handler(w http.ResponseWriter, r *http.Request) {    path := r.URL.Path    hits[path]++    fmt.Fprintf(w, "path %s seen %d times\n", path, hits[path])} func statsHandler(w http.ResponseWriter, r *http.Request) {    for p, n := range hits {        fmt.Fprintf(w, "%s = %d\n", p, n)    }} func main() {    http.HandleFunc("/", handler)    http.HandleFunc("/stats", statsHandler)    http.ListenAndServe(":8080", nil)}
Run or narrate your approach, then ask the coach.