This commit is contained in:
Teiva Harsanyi 2024-10-09 13:38:14 +02:00
parent 8d85d6cdef
commit a6c4ae916d
21 changed files with 266 additions and 259 deletions

View file

@ -1,5 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block announce %} {% block announce %}
📢 Two new full sections are now available: <a href="https://100go.co/5-interface-pollution/">#5: Interface pollution</a> and <a href="https://100go.co/92-false-sharing/">#92: Writing concurrent code that leads to false sharing</a>. 📢 I have just released a daily newsletter for coders: The Coder Cafe ☕. Feel free to have a look at <a href="https://thecoder.cafe">thecoder.cafe</a>.
{% endblock %} {% endblock %}

View file

@ -137,7 +137,7 @@
</button> </button>
📢 Two new full sections are now available: <a href="https://100go.co/5-interface-pollution/">#5: Interface pollution</a> and <a href="https://100go.co/92-false-sharing/">#92: Writing concurrent code that leads to false sharing</a>. 📢 I have just released a daily newsletter for coders: The Coder Cafe ☕. Feel free to have a look at <a href="https://thecoder.cafe">thecoder.cafe</a>.
</div> </div>

View file

@ -137,7 +137,7 @@
</button> </button>
📢 Two new full sections are now available: <a href="https://100go.co/5-interface-pollution/">#5: Interface pollution</a> and <a href="https://100go.co/92-false-sharing/">#92: Writing concurrent code that leads to false sharing</a>. 📢 I have just released a daily newsletter for coders: The Coder Cafe ☕. Feel free to have a look at <a href="https://thecoder.cafe">thecoder.cafe</a>.
</div> </div>

View file

@ -91,7 +91,7 @@
</button> </button>
📢 Two new full sections are now available: <a href="https://100go.co/5-interface-pollution/">#5: Interface pollution</a> and <a href="https://100go.co/92-false-sharing/">#92: Writing concurrent code that leads to false sharing</a>. 📢 I have just released a daily newsletter for coders: The Coder Cafe ☕. Feel free to have a look at <a href="https://thecoder.cafe">thecoder.cafe</a>.
</div> </div>

View file

@ -137,7 +137,7 @@
</button> </button>
📢 Two new full sections are now available: <a href="https://100go.co/5-interface-pollution/">#5: Interface pollution</a> and <a href="https://100go.co/92-false-sharing/">#92: Writing concurrent code that leads to false sharing</a>. 📢 I have just released a daily newsletter for coders: The Coder Cafe ☕. Feel free to have a look at <a href="https://thecoder.cafe">thecoder.cafe</a>.
</div> </div>
@ -1190,7 +1190,7 @@
<li><code>io.Writer</code> writes data to a target</li> <li><code>io.Writer</code> writes data to a target</li>
</ul> </ul>
<p>What is the rationale for having these two interfaces in the language? What is the point of creating these abstractions?</p> <p>What is the rationale for having these two interfaces in the language? What is the point of creating these abstractions?</p>
<p>Lets assume we need to implement a function that should copy the content of one file to another. We could create a specific function that would take as input two <code>*os.Files</code>. Or, we can choose to create a more generic function using <code>io.Reader</code> and <code>io.Writer</code> abstractions:</p> <p>Lets assume we need to implement a function that should copy the content of one file to another. We could create a specific function that would take as input two <code>*os.File</code>. Or, we can choose to create a more generic function using <code>io.Reader</code> and <code>io.Writer</code> abstractions:</p>
<div class="language-go highlight"><pre><span></span><code><span id="__span-2-1"><a id="__codelineno-2-1" name="__codelineno-2-1" href="#__codelineno-2-1"></a><span class="kd">func</span><span class="w"> </span><span class="nx">copySourceToDest</span><span class="p">(</span><span class="nx">source</span><span class="w"> </span><span class="nx">io</span><span class="p">.</span><span class="nx">Reader</span><span class="p">,</span><span class="w"> </span><span class="nx">dest</span><span class="w"> </span><span class="nx">io</span><span class="p">.</span><span class="nx">Writer</span><span class="p">)</span><span class="w"> </span><span class="kt">error</span><span class="w"> </span><span class="p">{</span> <div class="language-go highlight"><pre><span></span><code><span id="__span-2-1"><a id="__codelineno-2-1" name="__codelineno-2-1" href="#__codelineno-2-1"></a><span class="kd">func</span><span class="w"> </span><span class="nx">copySourceToDest</span><span class="p">(</span><span class="nx">source</span><span class="w"> </span><span class="nx">io</span><span class="p">.</span><span class="nx">Reader</span><span class="p">,</span><span class="w"> </span><span class="nx">dest</span><span class="w"> </span><span class="nx">io</span><span class="p">.</span><span class="nx">Writer</span><span class="p">)</span><span class="w"> </span><span class="kt">error</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-2-2"><a id="__codelineno-2-2" name="__codelineno-2-2" href="#__codelineno-2-2"></a><span class="w"> </span><span class="c1">// ...</span> </span><span id="__span-2-2"><a id="__codelineno-2-2" name="__codelineno-2-2" href="#__codelineno-2-2"></a><span class="w"> </span><span class="c1">// ...</span>
</span><span id="__span-2-3"><a id="__codelineno-2-3" name="__codelineno-2-3" href="#__codelineno-2-3"></a><span class="p">}</span> </span><span id="__span-2-3"><a id="__codelineno-2-3" name="__codelineno-2-3" href="#__codelineno-2-3"></a><span class="p">}</span>

View file

@ -137,7 +137,7 @@
</button> </button>
📢 Two new full sections are now available: <a href="https://100go.co/5-interface-pollution/">#5: Interface pollution</a> and <a href="https://100go.co/92-false-sharing/">#92: Writing concurrent code that leads to false sharing</a>. 📢 I have just released a daily newsletter for coders: The Coder Cafe ☕. Feel free to have a look at <a href="https://thecoder.cafe">thecoder.cafe</a>.
</div> </div>

View file

@ -137,7 +137,7 @@
</button> </button>
📢 Two new full sections are now available: <a href="https://100go.co/5-interface-pollution/">#5: Interface pollution</a> and <a href="https://100go.co/92-false-sharing/">#92: Writing concurrent code that leads to false sharing</a>. 📢 I have just released a daily newsletter for coders: The Coder Cafe ☕. Feel free to have a look at <a href="https://thecoder.cafe">thecoder.cafe</a>.
</div> </div>

View file

@ -137,7 +137,7 @@
</button> </button>
📢 Two new full sections are now available: <a href="https://100go.co/5-interface-pollution/">#5: Interface pollution</a> and <a href="https://100go.co/92-false-sharing/">#92: Writing concurrent code that leads to false sharing</a>. 📢 I have just released a daily newsletter for coders: The Coder Cafe ☕. Feel free to have a look at <a href="https://thecoder.cafe">thecoder.cafe</a>.
</div> </div>

View file

@ -137,7 +137,7 @@
</button> </button>
📢 Two new full sections are now available: <a href="https://100go.co/5-interface-pollution/">#5: Interface pollution</a> and <a href="https://100go.co/92-false-sharing/">#92: Writing concurrent code that leads to false sharing</a>. 📢 I have just released a daily newsletter for coders: The Coder Cafe ☕. Feel free to have a look at <a href="https://thecoder.cafe">thecoder.cafe</a>.
</div> </div>

View file

@ -137,7 +137,7 @@
</button> </button>
📢 Two new full sections are now available: <a href="https://100go.co/5-interface-pollution/">#5: Interface pollution</a> and <a href="https://100go.co/92-false-sharing/">#92: Writing concurrent code that leads to false sharing</a>. 📢 I have just released a daily newsletter for coders: The Coder Cafe ☕. Feel free to have a look at <a href="https://thecoder.cafe">thecoder.cafe</a>.
</div> </div>

View file

@ -137,7 +137,7 @@
</button> </button>
📢 Two new full sections are now available: <a href="https://100go.co/5-interface-pollution/">#5: Interface pollution</a> and <a href="https://100go.co/92-false-sharing/">#92: Writing concurrent code that leads to false sharing</a>. 📢 I have just released a daily newsletter for coders: The Coder Cafe ☕. Feel free to have a look at <a href="https://thecoder.cafe">thecoder.cafe</a>.
</div> </div>

View file

@ -137,7 +137,7 @@
</button> </button>
📢 Two new full sections are now available: <a href="https://100go.co/5-interface-pollution/">#5: Interface pollution</a> and <a href="https://100go.co/92-false-sharing/">#92: Writing concurrent code that leads to false sharing</a>. 📢 I have just released a daily newsletter for coders: The Coder Cafe ☕. Feel free to have a look at <a href="https://thecoder.cafe">thecoder.cafe</a>.
</div> </div>

View file

@ -135,7 +135,7 @@
</button> </button>
📢 Two new full sections are now available: <a href="https://100go.co/5-interface-pollution/">#5: Interface pollution</a> and <a href="https://100go.co/92-false-sharing/">#92: Writing concurrent code that leads to false sharing</a>. 📢 I have just released a daily newsletter for coders: The Coder Cafe ☕. Feel free to have a look at <a href="https://thecoder.cafe">thecoder.cafe</a>.
</div> </div>

View file

@ -137,7 +137,7 @@
</button> </button>
📢 Two new full sections are now available: <a href="https://100go.co/5-interface-pollution/">#5: Interface pollution</a> and <a href="https://100go.co/92-false-sharing/">#92: Writing concurrent code that leads to false sharing</a>. 📢 I have just released a daily newsletter for coders: The Coder Cafe ☕. Feel free to have a look at <a href="https://thecoder.cafe">thecoder.cafe</a>.
</div> </div>
@ -5087,7 +5087,7 @@ the use case. However, we should see the two options as complementary. </p>
</span><span id="__span-70-10"><a id="__codelineno-70-10" name="__codelineno-70-10" href="#__codelineno-70-10"></a><span class="w"> </span><span class="nx">fmt</span><span class="p">.</span><span class="nx">Println</span><span class="p">(</span><span class="nx">i</span><span class="p">)</span> </span><span id="__span-70-10"><a id="__codelineno-70-10" name="__codelineno-70-10" href="#__codelineno-70-10"></a><span class="w"> </span><span class="nx">fmt</span><span class="p">.</span><span class="nx">Println</span><span class="p">(</span><span class="nx">i</span><span class="p">)</span>
</span><span id="__span-70-11"><a id="__codelineno-70-11" name="__codelineno-70-11" href="#__codelineno-70-11"></a><span class="p">}</span> </span><span id="__span-70-11"><a id="__codelineno-70-11" name="__codelineno-70-11" href="#__codelineno-70-11"></a><span class="p">}</span>
</span></code></pre></div> </span></code></pre></div>
<p>Runnig this code with the <code>-race</code> logs the following warning:</p> <p>Running this code with the <code>-race</code> logs the following warning:</p>
<div class="language-bash highlight"><pre><span></span><code><span id="__span-71-1"><a id="__codelineno-71-1" name="__codelineno-71-1" href="#__codelineno-71-1"></a><span class="o">==================</span> <div class="language-bash highlight"><pre><span></span><code><span id="__span-71-1"><a id="__codelineno-71-1" name="__codelineno-71-1" href="#__codelineno-71-1"></a><span class="o">==================</span>
</span><span id="__span-71-2"><a id="__codelineno-71-2" name="__codelineno-71-2" href="#__codelineno-71-2"></a>WARNING:<span class="w"> </span>DATA<span class="w"> </span>RACE </span><span id="__span-71-2"><a id="__codelineno-71-2" name="__codelineno-71-2" href="#__codelineno-71-2"></a>WARNING:<span class="w"> </span>DATA<span class="w"> </span>RACE
</span><span id="__span-71-3"><a id="__codelineno-71-3" name="__codelineno-71-3" href="#__codelineno-71-3"></a><span class="hll">Write<span class="w"> </span>at<span class="w"> </span>0x00c000026078<span class="w"> </span>by<span class="w"> </span>goroutine<span class="w"> </span><span class="m">7</span>:<span class="w"> </span><span class="c1"># (1)</span> </span><span id="__span-71-3"><a id="__codelineno-71-3" name="__codelineno-71-3" href="#__codelineno-71-3"></a><span class="hll">Write<span class="w"> </span>at<span class="w"> </span>0x00c000026078<span class="w"> </span>by<span class="w"> </span>goroutine<span class="w"> </span><span class="m">7</span>:<span class="w"> </span><span class="c1"># (1)</span>

View file

@ -137,7 +137,7 @@
</button> </button>
📢 Two new full sections are now available: <a href="https://100go.co/5-interface-pollution/">#5: Interface pollution</a> and <a href="https://100go.co/92-false-sharing/">#92: Writing concurrent code that leads to false sharing</a>. 📢 I have just released a daily newsletter for coders: The Coder Cafe ☕. Feel free to have a look at <a href="https://thecoder.cafe">thecoder.cafe</a>.
</div> </div>

View file

@ -137,7 +137,7 @@
</button> </button>
📢 Two new full sections are now available: <a href="https://100go.co/5-interface-pollution/">#5: Interface pollution</a> and <a href="https://100go.co/92-false-sharing/">#92: Writing concurrent code that leads to false sharing</a>. 📢 I have just released a daily newsletter for coders: The Coder Cafe ☕. Feel free to have a look at <a href="https://thecoder.cafe">thecoder.cafe</a>.
</div> </div>

File diff suppressed because one or more lines are too long

View file

@ -2,77 +2,77 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url> <url>
<loc>https://100go.co/</loc> <loc>https://100go.co/</loc>
<lastmod>2024-10-06</lastmod> <lastmod>2024-10-09</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://100go.co/20-slice/</loc> <loc>https://100go.co/20-slice/</loc>
<lastmod>2024-10-06</lastmod> <lastmod>2024-10-09</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://100go.co/28-maps-memory-leaks/</loc> <loc>https://100go.co/28-maps-memory-leaks/</loc>
<lastmod>2024-10-06</lastmod> <lastmod>2024-10-09</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://100go.co/5-interface-pollution/</loc> <loc>https://100go.co/5-interface-pollution/</loc>
<lastmod>2024-10-06</lastmod> <lastmod>2024-10-09</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://100go.co/56-concurrency-faster/</loc> <loc>https://100go.co/56-concurrency-faster/</loc>
<lastmod>2024-10-06</lastmod> <lastmod>2024-10-09</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://100go.co/89-benchmarks/</loc> <loc>https://100go.co/89-benchmarks/</loc>
<lastmod>2024-10-06</lastmod> <lastmod>2024-10-09</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://100go.co/9-generics/</loc> <loc>https://100go.co/9-generics/</loc>
<lastmod>2024-10-06</lastmod> <lastmod>2024-10-09</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://100go.co/92-false-sharing/</loc> <loc>https://100go.co/92-false-sharing/</loc>
<lastmod>2024-10-06</lastmod> <lastmod>2024-10-09</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://100go.co/98-profiling-execution-tracing/</loc> <loc>https://100go.co/98-profiling-execution-tracing/</loc>
<lastmod>2024-10-06</lastmod> <lastmod>2024-10-09</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://100go.co/book/</loc> <loc>https://100go.co/book/</loc>
<lastmod>2024-10-06</lastmod> <lastmod>2024-10-09</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://100go.co/chapter-1/</loc> <loc>https://100go.co/chapter-1/</loc>
<lastmod>2024-10-06</lastmod> <lastmod>2024-10-09</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://100go.co/external/</loc> <loc>https://100go.co/external/</loc>
<lastmod>2024-10-06</lastmod> <lastmod>2024-10-09</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://100go.co/ja/</loc> <loc>https://100go.co/ja/</loc>
<lastmod>2024-10-06</lastmod> <lastmod>2024-10-09</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://100go.co/pt-br/</loc> <loc>https://100go.co/pt-br/</loc>
<lastmod>2024-10-06</lastmod> <lastmod>2024-10-09</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
<url> <url>
<loc>https://100go.co/zh/</loc> <loc>https://100go.co/zh/</loc>
<lastmod>2024-10-06</lastmod> <lastmod>2024-10-09</lastmod>
<changefreq>daily</changefreq> <changefreq>daily</changefreq>
</url> </url>
</urlset> </urlset>

Binary file not shown.

View file

@ -6,3 +6,10 @@
.md-typeset details { .md-typeset details {
font-size: 15px font-size: 15px
} }
.md-announce {
background-color: #f0f8ff; /* Light blue background */
padding: 10px;
border-radius: 5px;
color: #333;
}

File diff suppressed because it is too large Load diff