Sobes.tech
Junior — Middle

What happens if you write data to a non-buffered channel without checking its state or reading from it?

sobes.tech AI

Answer from AI

If you write data to an unbuffered channel in Go without checking if someone is ready to receive it (i.e., without reading from the channel), the write operation will block. This happens because an unbuffered channel requires the sender and receiver to be synchronized: the sender waits until the receiver reads the value. If the receiver is not ready, the write will hang, and the goroutine performing the write will be blocked, which can lead to a deadlock if other goroutines are also waiting.

What happens if you write data to a non-buffered… - sobes.tech