<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Go-Concurrency on cassiobotaro</title><link>https://cassiobotaro.dev/en/series/go-concurrency/</link><description>Recent content in Go-Concurrency on cassiobotaro</description><generator>Hugo</generator><language>en</language><lastBuildDate>Thu, 15 Oct 2026 08:39:11 -0300</lastBuildDate><atom:link href="https://cassiobotaro.dev/en/series/go-concurrency/index.xml" rel="self" type="application/rss+xml"/><item><title>Go Concurrency - Tee</title><link>https://cassiobotaro.dev/en/posts/go-concurrency-tee/</link><pubDate>Thu, 15 Oct 2026 00:00:00 +0000</pubDate><guid>https://cassiobotaro.dev/en/posts/go-concurrency-tee/</guid><description>&lt;video
 src="https://cassiobotaro.dev/videos/tee.mp4"
 title="Each value of a channel copied to every output" aria-label="Each value of a channel copied to every output"
 autoplay
 loop
 muted
 playsinline
 controls
 preload="metadata"
 style="width: 100%; height: auto;"&gt;
&lt;/video&gt;

&lt;p&gt;In the &lt;a href="https://cassiobotaro.dev/en/posts/go-concurrency-fan-out/" &gt;fan-out&lt;/a&gt; each value went to only one worker.&lt;/p&gt;
&lt;p&gt;But what if both need to see everything? One writes to the log and the other updates a metric, for example. Neither of them can miss a value.&lt;/p&gt;
&lt;h2 id="what-a-tee-is"&gt;
 What a tee is
 &lt;a class="heading-link" href="#what-a-tee-is"&gt;
 &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;
 &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;
 &lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;A tee copies each value of an input channel to all the output channels. The name comes from the Unix &lt;code&gt;tee&lt;/code&gt; command, which duplicates whatever it receives.&lt;/p&gt;</description></item><item><title>Go Concurrency - Fan-out</title><link>https://cassiobotaro.dev/en/posts/go-concurrency-fan-out/</link><pubDate>Tue, 13 Oct 2026 00:00:00 +0000</pubDate><guid>https://cassiobotaro.dev/en/posts/go-concurrency-fan-out/</guid><description>&lt;video
 src="https://cassiobotaro.dev/videos/fan_out.mp4"
 title="Three workers splitting the values of the same channel" aria-label="Three workers splitting the values of the same channel"
 autoplay
 loop
 muted
 playsinline
 controls
 preload="metadata"
 style="width: 100%; height: auto;"&gt;
&lt;/video&gt;

&lt;p&gt;In the &lt;a href="https://cassiobotaro.dev/en/posts/go-concurrency-worker/" &gt;worker&lt;/a&gt; the &lt;code&gt;fmt.Printf&lt;/code&gt; played the role of the processing. Now let&amp;rsquo;s pretend it takes a while.&lt;/p&gt;
&lt;p&gt;A &lt;code&gt;time.Sleep&lt;/code&gt; of 100 milliseconds per value. There are ten values, in other words, one second staring at the screen.&lt;/p&gt;
&lt;p&gt;What if I put three workers reading from the same channel?&lt;/p&gt;</description></item><item><title>Go Concurrency - Pipeline</title><link>https://cassiobotaro.dev/en/posts/go-concurrency-pipeline/</link><pubDate>Thu, 08 Oct 2026 00:00:00 +0000</pubDate><guid>https://cassiobotaro.dev/en/posts/go-concurrency-pipeline/</guid><description>&lt;video
 src="https://cassiobotaro.dev/videos/pipeline.mp4"
 title="Stages chained by channels, each one transforming what it receives" aria-label="Stages chained by channels, each one transforming what it receives"
 autoplay
 loop
 muted
 playsinline
 controls
 preload="metadata"
 style="width: 100%; height: auto;"&gt;
&lt;/video&gt;

&lt;p&gt;In the &lt;a href="https://cassiobotaro.dev/en/posts/go-concurrency-generators/" &gt;generator&lt;/a&gt; a goroutine wrote to the channel. In the &lt;a href="https://cassiobotaro.dev/en/posts/go-concurrency-worker/" &gt;worker&lt;/a&gt; it read from it.&lt;/p&gt;
&lt;p&gt;What if it does both? It reads from a channel, transforms the value and writes to another.&lt;/p&gt;
&lt;h2 id="what-a-pipeline-is"&gt;
 What a pipeline is
 &lt;a class="heading-link" href="#what-a-pipeline-is"&gt;
 &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;
 &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;
 &lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;A pipeline is a chain of stages connected by channels. Each stage is a function that receives a channel, starts a goroutine to read from it and returns the channel where it writes the result.&lt;/p&gt;</description></item><item><title>Go Concurrency - Worker</title><link>https://cassiobotaro.dev/en/posts/go-concurrency-worker/</link><pubDate>Tue, 06 Oct 2026 00:00:00 +0000</pubDate><guid>https://cassiobotaro.dev/en/posts/go-concurrency-worker/</guid><description>&lt;video
 src="https://cassiobotaro.dev/videos/trabalhador.mp4"
 title="A goroutine consuming values from a channel" aria-label="A goroutine consuming values from a channel"
 autoplay
 loop
 muted
 playsinline
 controls
 preload="metadata"
 style="width: 100%; height: auto;"&gt;
&lt;/video&gt;

&lt;p&gt;In the &lt;a href="https://cassiobotaro.dev/en/posts/go-concurrency-generators/" &gt;generator&lt;/a&gt; a goroutine wrote to the channel and &lt;code&gt;main&lt;/code&gt; read from it.&lt;/p&gt;
&lt;p&gt;Now the roles flip. The one reading is the goroutine.&lt;/p&gt;
&lt;h2 id="what-a-worker-is"&gt;
 What a worker is
 &lt;a class="heading-link" href="#what-a-worker-is"&gt;
 &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;
 &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;
 &lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;A worker is a goroutine that receives values from a channel and processes them until the channel is closed.&lt;/p&gt;</description></item><item><title>Go Concurrency - Generators</title><link>https://cassiobotaro.dev/en/posts/go-concurrency-generators/</link><pubDate>Thu, 01 Oct 2026 00:00:00 +0000</pubDate><guid>https://cassiobotaro.dev/en/posts/go-concurrency-generators/</guid><description>&lt;video
 src="https://cassiobotaro.dev/videos/geradores.mp4"
 title="A goroutine producing values on a channel" aria-label="A goroutine producing values on a channel"
 autoplay
 loop
 muted
 playsinline
 controls
 preload="metadata"
 style="width: 100%; height: auto;"&gt;
&lt;/video&gt;

&lt;p&gt;In the &lt;a href="https://cassiobotaro.dev/en/posts/go-concurrency-hello-world/" &gt;hello world&lt;/a&gt; the channel carried a single message, from the goroutine to &lt;code&gt;main&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;But it&amp;rsquo;s almost never a single message. It&amp;rsquo;s the lines of a file, the pages of an API, the events of a queue. And this is where the first pattern of the series comes in.&lt;/p&gt;</description></item><item><title>Go Concurrency - Hello world</title><link>https://cassiobotaro.dev/en/posts/go-concurrency-hello-world/</link><pubDate>Thu, 24 Sep 2026 00:00:00 +0000</pubDate><guid>https://cassiobotaro.dev/en/posts/go-concurrency-hello-world/</guid><description>&lt;video
 src="https://cassiobotaro.dev/videos/ola_mundo.mp4"
 title="A goroutine sending a message through a channel" aria-label="A goroutine sending a message through a channel"
 autoplay
 loop
 muted
 playsinline
 controls
 preload="metadata"
 style="width: 100%; height: auto;"&gt;
&lt;/video&gt;

&lt;p&gt;A few years ago I watched a &lt;a href="https://github.com/andrebq/andrebq.github.io" class="external-link" target="_blank" rel="noopener"&gt;talk&lt;/a&gt; by &lt;a href="https://github.com/andrebq" class="external-link" target="_blank" rel="noopener"&gt;@andrebq&lt;/a&gt; about concurrency in Go and my mind was blown.&lt;/p&gt;
&lt;p&gt;Much later I decided to transcribe the examples from that talk into a repository, and kept adding others I found in books, in articles and in Rob Pike&amp;rsquo;s talk &lt;a href="https://go.dev/talks/2012/concurrency.slide" class="external-link" target="_blank" rel="noopener"&gt;Go Concurrency Patterns&lt;/a&gt;. It became &lt;a href="https://github.com/cassiobotaro/concorrencia-go" class="external-link" target="_blank" rel="noopener"&gt;concorrencia-go&lt;/a&gt;.&lt;/p&gt;</description></item></channel></rss>