Ask your AI Ask your AI to turn this code into a guided bug-finding exercise.
Claude ChatGPT I am reading "An `io.Reader` returns `n > 0` and `err == io.EOF` in the same call. What should the caller do?" on CodeWiki (https://codewiki.com/practice/mcq/go/checkpoint-4/checkpoint-4-reader-contract/).
Context (verbatim from the page):
"""
An `io.Reader` returns `n > 0` and `err == io.EOF` in the same call. What should the caller do?
Process the first `n` bytes, then handle the EOF.
Discard the bytes because every non-nil error invalidates `n`.
Retry the same read until it returns the bytes with a nil error.
"""
Introduce three subtle bugs into the example above and let me find them. Reveal each answer only after I have guessed.
Answer in English. Keep code examples in Go. Where you are unsure, say so.