Code Room
Vibe codingHard
Question
An AI wrote this Go fan-out helper that queries N replicas and returns the first response. It compiles and the happy path works. Review it for cancellation and leaks.
func QueryFastest(ctx context.Context, replicas []string, q string) (string, error) { results := make(chan string) for _, r := range replicas { go func(addr string) { resp, err := queryReplica(ctx, addr, q) if err == nil { results <- resp } }(r) } select { case res := <-results: return res, nil case <-ctx.Done(): return "", ctx.Err() }}What resource problem does this have, and how do you fix it?
What a strong answer looks like
Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it — tests, edge cases, reading critically — and how you’d re-prompt or decompose to get it right.
Learn the concepts
Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.
Run or narrate your approach, then ask the coach.