<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Programming on Loïc Sikidi</title><link>https://words.lsikidi.com/tags/programming/</link><description>Recent content in Programming on Loïc Sikidi</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Sun, 10 May 2026 00:22:49 +0200</lastBuildDate><atom:link href="https://words.lsikidi.com/tags/programming/index.xml" rel="self" type="application/rss+xml"/><item><title>Why I Prefer Structs Over Variadic Functions in Go</title><link>https://words.lsikidi.com/posts/002-why-i-prefer-structs-over-variadic-funcs/</link><pubDate>Sun, 10 May 2026 00:22:49 +0200</pubDate><guid>https://words.lsikidi.com/posts/002-why-i-prefer-structs-over-variadic-funcs/</guid><description>&lt;p&gt;After several years of practicing Go, I must admit that I&amp;rsquo;m not a big fan of variadic functions&lt;sup id="fnref:1"&gt;&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref"&gt;1&lt;/a&gt;&lt;/sup&gt;. I&amp;rsquo;ll try to explain why and why I greatly prefer using &lt;em&gt;structs&lt;/em&gt;.&lt;/p&gt;
&lt;h2 id="definition"&gt;Definition&lt;/h2&gt;
&lt;p&gt;Let&amp;rsquo;s start with a quick reminder of what variadic functions are for those unfamiliar with the concept.&lt;/p&gt;
&lt;p&gt;This pattern is generally used to configure options in a flexible/dynamic way when creating an instance of a structure.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s look at a concrete example:&lt;/p&gt;</description></item><item><title>Making Go APIs More Ergonomic with Optional Arguments</title><link>https://words.lsikidi.com/posts/001-optional-arg-is-dope/</link><pubDate>Sat, 09 May 2026 11:14:30 +0200</pubDate><guid>https://words.lsikidi.com/posts/001-optional-arg-is-dope/</guid><description>&lt;h2 id="introduction"&gt;Introduction&lt;/h2&gt;
&lt;p&gt;In Go, as in all programming languages, it&amp;rsquo;s sometimes useful to have optional arguments in functions.&lt;/p&gt;
&lt;p&gt;The Go language supports this functionality but in a very limited way, as shown in the example below:&lt;/p&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&gt;&lt;span style="color:#66d9ef"&gt;func&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;Greetings&lt;/span&gt;(&lt;span style="color:#a6e22e"&gt;name&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;string&lt;/span&gt;, &lt;span style="color:#a6e22e"&gt;age&lt;/span&gt; &lt;span style="color:#f92672"&gt;...&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;int&lt;/span&gt;) {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; len(&lt;span style="color:#a6e22e"&gt;age&lt;/span&gt;) &amp;gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;fmt&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;Printf&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;Hello %s, you are %d years old\n&amp;#34;&lt;/span&gt;, &lt;span style="color:#a6e22e"&gt;name&lt;/span&gt;, &lt;span style="color:#a6e22e"&gt;age&lt;/span&gt;[&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;])
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; } &lt;span style="color:#66d9ef"&gt;else&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;fmt&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;Printf&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;Hello %s\n&amp;#34;&lt;/span&gt;, &lt;span style="color:#a6e22e"&gt;name&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;func&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;main&lt;/span&gt;() {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;Greetings&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;Alice&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;Greetings&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;Bob&amp;#34;&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;30&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;Greetings&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#34;Chad&amp;#34;&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;40&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;100&lt;/span&gt;) &lt;span style="color:#75715e"&gt;// only the first value is used&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="alert alert-note" role="alert"&gt;
&lt;div class="alert-title"&gt;
&lt;span class="alert-icon"&gt;&lt;/span&gt;
&lt;span class="alert-type-label"&gt;Note&lt;/span&gt;&lt;/div&gt;
&lt;div class="alert-content"&gt;
&lt;p&gt;The complete example is available via the Go playground: &lt;a href="https://go.dev/play/p/HBzgGmQQBsd"&gt;here&lt;/a&gt;.&lt;/p&gt;</description></item></channel></rss>