Code Room
Code reviewMedium
Question
Review this Go TCP client snippet. It reads a length-prefixed message from a server.
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 readMessage(conn net.Conn) ([]byte, error) { var header [4]byte if _, err := conn.Read(header[:]); err != nil { return nil, err } n := binary.BigEndian.Uint32(header[:]) buf := make([]byte, n) if _, err := conn.Read(buf); err != nil { return nil, err } return buf, nil}Run or narrate your approach, then ask the coach.