<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Closures on The Blog of Boban Acimovic</title><link>https://acim.net/tags/closures/</link><description>Recent content in Closures on The Blog of Boban Acimovic</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><copyright>The Blog of Boban Acimovic &amp;copy; 2026</copyright><lastBuildDate>Fri, 04 Oct 2019 00:00:00 +0000</lastBuildDate><atom:link href="https://acim.net/tags/closures/index.xml" rel="self" type="application/rss+xml"/><item><title>Generators, wait groups and closures in Golang</title><link>https://acim.net/blog/generators-waitgroups-closures-golang/</link><pubDate>Fri, 04 Oct 2019 00:00:00 +0000</pubDate><guid>https://acim.net/blog/generators-waitgroups-closures-golang/</guid><description>&lt;p&gt;This is the first step of my intention to write a series of articles where I would explain some common patterns used in Golang. Let&amp;rsquo;s start with &lt;a href="https://en.wikipedia.org/wiki/Generator_%28computer_programming%29" target="_blank" rel="noopener"&gt;generator pattern&lt;/a&gt;
:&lt;/p&gt;
&lt;div class="highlight-wrapper"&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-go" data-lang="go"&gt;&lt;span style="display:flex;"&gt;&lt;span style="white-space:pre;-webkit-user-select:none;user-select:none;margin-right:0.4em;padding:0 0.4em 0 0.4em;color:#7f7f7f"&gt;1&lt;/span&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;type&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Generator&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;func&lt;/span&gt;() &lt;span style="color:#f92672"&gt;&amp;lt;-&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;chan&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;int&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Generator is a function or method which returns a sequence of values. In Golang, this usually means returning a channel of values of desired type. In our example, we will return a channel of integers. Let&amp;rsquo;s see an implementation of this:&lt;/p&gt;</description></item></channel></rss>