Go code
ch := make(chan int)
ch <- 1Line-by-line explanation
- An unbuffered channel is created.
- Main tries to send.
- No other goroutine can receive.
- The program deadlocks.
Expected output
fatal error: all goroutines are asleep - deadlock!This is the expected result.
Use channels, mutexes, ownership, and cancellation deliberately. Run tests with go test -race to help find data races.