<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Channel on iMil.net</title>
    <link>http://imil.net/blog/tags/channel/</link>
    <description>Recent content in Channel on iMil.net</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 31 Dec 2018 17:06:42 +0000</lastBuildDate>
    <atom:link href="http://imil.net/blog/tags/channel/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Understanding golang channel range</title>
      <link>http://imil.net/blog/posts/2018/understanding-golang-channel-range/</link>
      <pubDate>Mon, 31 Dec 2018 17:06:42 +0000</pubDate>
      <guid>http://imil.net/blog/posts/2018/understanding-golang-channel-range/</guid>
      <description>&lt;p&gt;Here we go again with my &lt;a href=&#34;https://golang.org&#34;&gt;golang&lt;/a&gt; self teaching, today with a topic I had hard time understanding correctly (and hope I actually did): &lt;code&gt;range over channels&lt;/code&gt; along with &lt;code&gt;goroutines&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;First of all, let&amp;rsquo;s have a little reminder. We all know a &lt;code&gt;goroutine&lt;/code&gt; live its own life and must be waited for at the &lt;code&gt;main level&lt;/code&gt;, i.e. in this example:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-go&#34; data-lang=&#34;go&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;package&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;main&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;fmt&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;func&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;main&lt;/span&gt;() {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#x9;&lt;span style=&#34;color:#66d9ef&#34;&gt;go&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;func&lt;/span&gt;() {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#x9;&#x9;&lt;span style=&#34;color:#a6e22e&#34;&gt;fmt&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Println&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;hello there&amp;#34;&lt;/span&gt;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#x9;}()&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&#34;https://play.golang.org/p/cbczlMV4_0p&#34;&gt;run me on playground&lt;/a&gt;&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
