Consider the following snippet:
(let [chs (repeatedly 10 chan)]
(doseq [c chs]
(>!! c \"hello\"))
(doseq [c chs]
(println (
That channel has no buffer, and >!!
is blocking. Refer to the examples for this exact case. They spawn a second thread for this reason - to prevent blocking the main thread. Using a goroutine, as in your question, operates on a similar principle.
You can also create the channel with some buffer space - (chan 1)