Code Room
Code reviewMediumcr-g132
Subject Input validationLevel Mid–Senior~20 minCommon in Code quality & review interviewsIndustries Software development

Question

Review this Go money-transfer handler.

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
func TransferHandler(w http.ResponseWriter, r *http.Request) {    var req struct {        To     string  `json:"to"`        Amount float64 `json:"amount"`    }    if err := json.NewDecoder(r.Body).Decode(&req); err != nil {        http.Error(w, "bad request", 400)        return    }    if req.Amount > balance(r.Context()) {        http.Error(w, "insufficient funds", 400)        return    }    debit(req.To, req.Amount)    w.WriteHeader(204)}
Run or narrate your approach, then ask the coach.