<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Golang on iMil.net</title>
    <link>http://imil.net/blog/tags/golang/</link>
    <description>Recent content in Golang on iMil.net</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 04 May 2020 05:54:59 +0200</lastBuildDate>
    <atom:link href="http://imil.net/blog/tags/golang/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Generate All Boolean Array Combinations</title>
      <link>http://imil.net/blog/posts/2020/generate-all-boolean-array-combinations/</link>
      <pubDate>Mon, 04 May 2020 05:54:59 +0200</pubDate>
      <guid>http://imil.net/blog/posts/2020/generate-all-boolean-array-combinations/</guid>
      <description>&lt;p&gt;While writing &lt;a href=&#34;https://golang.org/pkg/testing/&#34;&gt;Go tests&lt;/a&gt; for &lt;a href=&#34;https://gitlab.com/iMil/goxplorer&#34;&gt;goxplorer&lt;/a&gt;, I wanted to test all boolean flags combinations without having to cascade &lt;code&gt;for&lt;/code&gt; loops.&lt;br&gt;&#xA;This first method came to mind:&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; (&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#x9;&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;&#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;stob&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;bf&lt;/span&gt; []&lt;span style=&#34;color:#66d9ef&#34;&gt;bool&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;s&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;string&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;for&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;i&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;b&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;range&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;s&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:#66d9ef&#34;&gt;if&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;b&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;==&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;0&amp;#39;&lt;/span&gt; {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#x9;&#x9;&#x9;&lt;span style=&#34;color:#a6e22e&#34;&gt;bf&lt;/span&gt;[&lt;span style=&#34;color:#a6e22e&#34;&gt;i&lt;/span&gt;] = &lt;span style=&#34;color:#66d9ef&#34;&gt;false&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:#66d9ef&#34;&gt;else&lt;/span&gt; {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#x9;&#x9;&#x9;&lt;span style=&#34;color:#a6e22e&#34;&gt;bf&lt;/span&gt;[&lt;span style=&#34;color:#a6e22e&#34;&gt;i&lt;/span&gt;] = &lt;span style=&#34;color:#66d9ef&#34;&gt;true&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#x9;&#x9;}&#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;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:#a6e22e&#34;&gt;bf&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt; []&lt;span style=&#34;color:#66d9ef&#34;&gt;bool&lt;/span&gt;{&lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;, &lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;, &lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;, &lt;span style=&#34;color:#66d9ef&#34;&gt;false&lt;/span&gt;, &lt;span style=&#34;color:#66d9ef&#34;&gt;false&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;&#x9;&lt;span style=&#34;color:#66d9ef&#34;&gt;for&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;i&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;; &lt;span style=&#34;color:#a6e22e&#34;&gt;i&lt;/span&gt; &amp;lt; &lt;span style=&#34;color:#ae81ff&#34;&gt;32&lt;/span&gt;; &lt;span style=&#34;color:#a6e22e&#34;&gt;i&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;++&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;b&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;fmt&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;Sprintf&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;%b&amp;#34;&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;i&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;stob&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;bf&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;b&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:#a6e22e&#34;&gt;bf&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;Because the fastest way of generating every possible combination of 5 bits is to count from 0 to 31, i.e. &lt;code&gt;2^5&lt;/code&gt;, i.e. 32. The second trick here is to use &lt;code&gt;fmt.Sprintf(&amp;quot;%b&amp;quot;)&lt;/code&gt; to generate a &lt;code&gt;string&lt;/code&gt; representing the binary value.&lt;br&gt;&#xA;It works, but I found the idea of using &lt;code&gt;string&lt;/code&gt;s too heavy for a &amp;ldquo;binary&amp;rdquo; task.&lt;br&gt;&#xA;A friend came to me with a barbaric bits field solution I found way too smart / complicated :), so I thought about another option but also using bits field, and thought about the following: how to tell if a field is a &lt;code&gt;1&lt;/code&gt;? One of the many options is the &lt;code&gt;or&lt;/code&gt; binary operator; indeed, if a field is &lt;code&gt;0&lt;/code&gt; and is &amp;ldquo;or&amp;rsquo;ed&amp;rdquo; with a &lt;code&gt;1&lt;/code&gt;, its value will become &lt;code&gt;1&lt;/code&gt;, if the initial value is &lt;code&gt;1&lt;/code&gt;, it will not change. Remember &lt;code&gt;or&lt;/code&gt; truth table?&lt;/p&gt;</description>
    </item>
    <item>
      <title>Is LevelDB 2 times faster than BadgerDB? (Update: No)</title>
      <link>http://imil.net/blog/posts/2019/is-leveldb-2-times-faster-than-badgerdb/</link>
      <pubDate>Thu, 19 Dec 2019 17:31:30 +0000</pubDate>
      <guid>http://imil.net/blog/posts/2019/is-leveldb-2-times-faster-than-badgerdb/</guid>
      <description>&lt;p&gt;&lt;strong&gt;Update (2020/05/21)&lt;/strong&gt; the method used in this post is totally sub-performant, and I finally found out about &lt;em&gt;LevelDB&lt;/em&gt;&amp;rsquo;s and &lt;em&gt;Badger&lt;/em&gt;&amp;rsquo;s &lt;code&gt;batch&lt;/code&gt; methods, which make writes considerably faster, I&amp;rsquo;ll probably write another note about this.&lt;br&gt;&#xA;And by the way, I found &lt;em&gt;Badger&lt;/em&gt; to be much faster at writing &lt;em&gt;batches&lt;/em&gt; than &lt;em&gt;LevelDB&lt;/em&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Actual post&lt;/strong&gt;&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;m working on a plugin for &lt;a href=&#34;https://gitlab.com/iMil/goxplorer&#34;&gt;Goxplorer&lt;/a&gt; that will create a database of all &lt;em&gt;Bitcoin&lt;/em&gt; addresses present in its &lt;em&gt;blockchain&lt;/em&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Gitlab CI caching for Go projects</title>
      <link>http://imil.net/blog/posts/2019/gitlab-ci-caching-for-go-projects/</link>
      <pubDate>Sat, 07 Dec 2019 10:50:14 +0000</pubDate>
      <guid>http://imil.net/blog/posts/2019/gitlab-ci-caching-for-go-projects/</guid>
      <description>&lt;p&gt;The reference documentation when it comes to couple &lt;em&gt;golang&lt;/em&gt; and &lt;em&gt;continuous integration&lt;/em&gt; in &lt;a href=&#34;https://gitlab.com&#34;&gt;Gitlab&lt;/a&gt; is &lt;a href=&#34;https://about.gitlab.com/blog/2017/11/27/go-tools-and-gitlab-how-to-do-continuous-integration-like-a-boss/&#34;&gt;this one&lt;/a&gt;, it&amp;rsquo;s well put, easy to read and pretty accurate. Except for the &lt;code&gt;caching&lt;/code&gt; part, or at least nowadays with &lt;a href=&#34;https://github.com/golang/go/wiki/Modules&#34;&gt;go modules&lt;/a&gt;. This is what happens when a commit is pushed with the &lt;code&gt;.gitlab-ci.yml&lt;/code&gt; given as an example in that document:&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-plaintext&#34; data-lang=&#34;plaintext&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;131 Creating cache default...&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;132 WARNING: /apt-cache: no matching files&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;133 WARNING: /go/src/github.com: no matching files&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;134 WARNING: /go/src/gitlab.com: no matching files&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;135 WARNING: /go/src/golang.org: no matching files&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;136 WARNING: /go/src/google.golang.org: no matching files&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;137 WARNING: /go/src/gopkg.in: no matching files&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And as a matter of fact, the cache is empty for next stage.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Understanding golang channel range... again</title>
      <link>http://imil.net/blog/posts/2019/understanding-golang-channel-range-again/</link>
      <pubDate>Wed, 27 Nov 2019 11:17:40 +0000</pubDate>
      <guid>http://imil.net/blog/posts/2019/understanding-golang-channel-range-again/</guid>
      <description>&lt;p&gt;In a &lt;a href=&#34;https://imil.net/blog/2018/12/31/Understanding-golang-channel-range/&#34;&gt;previous article&lt;/a&gt;, I tried to explain my understanding of go &lt;em&gt;channels&lt;/em&gt; interaction with &lt;em&gt;ranges&lt;/em&gt;. Turns out my explanation was probably not clear enough because here I am, nearly a year after, struggling to achieve pretty much the same exercise.&lt;/p&gt;&#xA;&lt;p&gt;So here we go again, on a good old trial and error fashion progress.&lt;/p&gt;&#xA;&lt;p&gt;The goal here is to retrieve &lt;em&gt;channel&lt;/em&gt; messages that are pushed from go routines created in a &lt;em&gt;for&lt;/em&gt; loop.&lt;/p&gt;</description>
    </item>
    <item>
      <title>proof-of-work based blockchain explained with golang</title>
      <link>http://imil.net/blog/posts/2019/proof-of-work-based-blockchain-explained-with-golang/</link>
      <pubDate>Sat, 12 Oct 2019 17:44:52 +0000</pubDate>
      <guid>http://imil.net/blog/posts/2019/proof-of-work-based-blockchain-explained-with-golang/</guid>
      <description>&lt;p&gt;Yet another &amp;ldquo;blockchain explained&amp;rdquo; article, I know, I really thought about if releasing it or not, but you know, you only understand what you can explain clearly, so I hope I&amp;rsquo;ll be able to explain proof of work and blockchain as clearly as it is clear in my mind.&lt;br&gt;&#xA;The originality of this post is that I&amp;rsquo;ll try to make those concepts clear through pieces of code extensively explained so it doesn&amp;rsquo;t feel like a theoretical expose where you get the idea without the taste.&lt;/p&gt;</description>
    </item>
    <item>
      <title>golang reflection tips</title>
      <link>http://imil.net/blog/posts/2019/golang-reflection-tips/</link>
      <pubDate>Fri, 01 Mar 2019 17:16:48 +0000</pubDate>
      <guid>http://imil.net/blog/posts/2019/golang-reflection-tips/</guid>
      <description>&lt;p&gt;Because I&amp;rsquo;m the kind of person who likes genericity, I often find myself using features of languages that are flagged as &lt;em&gt;&amp;ldquo;only use it if you know what you&amp;rsquo;re doing&amp;rdquo;&lt;/em&gt;. &lt;em&gt;Golang reflection&lt;/em&gt; is one of those features, powerful yet a bit confusing.&lt;/p&gt;&#xA;&lt;p&gt;Reflection, as explained in &lt;a href=&#34;https://golang.org/pkg/reflect/&#34;&gt;The Laws of Reflection&lt;/a&gt; is &lt;em&gt;the ability of a program to examine its own structure, particularly through types; it&amp;rsquo;s a form of metaprogramming&lt;/em&gt;&lt;/p&gt;&#xA;&lt;p&gt;In short, you can introspect variables at run-time, making your program exceptionally dynamic. How can this serve any purpose? well imagine for example creating function names dynamically by another function parameter. Pretty cool uh?&lt;/p&gt;</description>
    </item>
    <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>
    <item>
      <title>Golang interfaces, a pragmatic explanation for the programmer</title>
      <link>http://imil.net/blog/posts/2018/golang-interfaces-a-pragmatic-explanation-for-the-programmer/</link>
      <pubDate>Sun, 09 Dec 2018 11:10:32 +0000</pubDate>
      <guid>http://imil.net/blog/posts/2018/golang-interfaces-a-pragmatic-explanation-for-the-programmer/</guid>
      <description>&lt;p&gt;I&amp;rsquo;m still in the process of learning &lt;a href=&#34;https://golang.org/&#34;&gt;golang&lt;/a&gt; the right way. Yes I already wrote some projects with the &lt;em&gt;Go&lt;/em&gt; language (&lt;a href=&#34;https://gitlab.com/iMil/js2sh&#34;&gt;here&lt;/a&gt; and &lt;a href=&#34;https://gitlab.com/iMil/collectd-ticker&#34;&gt;here&lt;/a&gt;), but I like to understand the real meaning of techniques when using them.&lt;br&gt;&#xA;One of what is said to be the most amazing features of &lt;em&gt;Go&lt;/em&gt; is &lt;a href=&#34;https://tour.golang.org/methods/9&#34;&gt;interfaces&lt;/a&gt;. Here&amp;rsquo;s what the official &lt;a href=&#34;https://golang.org/doc/effective_go.html#interfaces&#34;&gt;golang docs&lt;/a&gt; has to say about it:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Interfaces in Go provide a way to specify the behavior of an object: if something can do this, then it can be used here. We&amp;rsquo;ve seen a couple of simple examples already; custom printers can be implemented by a String method while Fprintf can generate output to anything with a Write method. Interfaces with only one or two methods are common in Go code, and are usually given a name derived from the method, such as io.Writer for something that implements Write.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
