An execution context stack records the active function calls within a goroutine. Each call to go creates a separate function stack, so concurrent handlers do not share a path for panic recovery. section 4.3.5
In a concurrent Go server:
- listen accepts a connection and starts handle in a new goroutine. section 4.3.5
- handle, response, and their nested calls occupy that goroutine's stack. section 4.3.5
- A panic unwinds the current stack until recover runs; it cannot jump to the stack of the initiating function. section 4.3.5
Protecting a request handler
Wrap handle with defer and recover, log the recovered error, and close the connection. A reusable safely.Go wrapper applies the same boundary to arbitrary goroutine work.







