Channels
Channels are how goroutines talk to each other — typed pipes you send values through and receive values from, using the <- operator.
ch <- v // Send v to channel ch.
v := <-ch // Receive from ch, and
// assign value to v.
The data flows in the direction of the arrow. Like maps and slices, channels need to be created before use:
ch := make(chan int)
By default, sends and receives block until both sides are ready. That blocking behavior is the feature — it’s built-in synchronization with no locks required.
Try it: the example splits a slice across two goroutines, sums each half in parallel, then collects both results through a single channel. Two receives, two answers, one final sum.