<?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>Metudu</title>
    <link>https://metudu.github.io/</link>
    <description>Recent content on Metudu</description>
    <generator>Hugo -- 0.152.2</generator>
    <language>en</language>
    <lastBuildDate>Tue, 25 Nov 2025 11:38:09 +0300</lastBuildDate>
    <atom:link href="https://metudu.github.io/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Test Helper Function in Go</title>
      <link>https://metudu.github.io/posts/test-helper-function-in-go/</link>
      <pubDate>Tue, 25 Nov 2025 11:38:09 +0300</pubDate>
      <guid>https://metudu.github.io/posts/test-helper-function-in-go/</guid>
      <description>&lt;p&gt;In software development, &lt;strong&gt;testing&lt;/strong&gt; is a fundamental concept that ensures our program functions exactly as intended. By writing comprehensive tests, we verify that everything works as expected and that we have adequately handled the various situations our code may encounter.&lt;/p&gt;
&lt;p&gt;In this post, I will briefly explain the concept of the &lt;strong&gt;test helper function&lt;/strong&gt; in Go. Utilizing this feature can significantly enhance the readability and reliability of your test code.&lt;/p&gt;</description>
    </item>
    <item>
      <title>What Is N&#43;1 Problem?</title>
      <link>https://metudu.github.io/posts/what-is-n&#43;1-problem/</link>
      <pubDate>Tue, 11 Nov 2025 13:59:04 +0300</pubDate>
      <guid>https://metudu.github.io/posts/what-is-n&#43;1-problem/</guid>
      <description>&lt;h2 id=&#34;understanding-n1&#34;&gt;Understanding N+1&lt;/h2&gt;
&lt;p&gt;The N+1 problem occurs when you make &lt;strong&gt;one&lt;/strong&gt; query to fetch &lt;em&gt;N&lt;/em&gt; objects, and then loop through those objects and make &lt;strong&gt;N additional queries&lt;/strong&gt;. When combined, this results in a total of &lt;strong&gt;N+1 queries&lt;/strong&gt;.&lt;/p&gt;
&lt;h2 id=&#34;illustrating-with-an-example&#34;&gt;Illustrating with an example&lt;/h2&gt;
&lt;p&gt;Consider the following example:&lt;/p&gt;
&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:#a6e22e&#34;&gt;books&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;:=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;db&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;getBooks&lt;/span&gt;() 
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here, we are simply retrieving all the books from the database. this is &lt;strong&gt;one&lt;/strong&gt; simple query that returns &lt;strong&gt;N&lt;/strong&gt; objects.&lt;/p&gt;
&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:#66d9ef&#34;&gt;for&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;index&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;book&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;books&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#a6e22e&#34;&gt;authors&lt;/span&gt; = append(&lt;span style=&#34;color:#a6e22e&#34;&gt;authors&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;db&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;getAuthor&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;book&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;author_id&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;What we just did is iterate through the N books and fetch the author for each one. The &lt;code&gt;db.getAuthor()&lt;/code&gt; function run &lt;strong&gt;N times&lt;/strong&gt;, which means we executed &lt;strong&gt;N additional queries&lt;/strong&gt;.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
