Code Room
Code reviewMedium
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.
Learn the concepts
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.