<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Maps on Nalar</title>
    <link>https://nalar.dev/tags/maps/</link>
    <description>Recent content in Maps on Nalar</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Thu, 10 Sep 2026 00:00:00 +0700</lastBuildDate>
    <atom:link href="https://nalar.dev/tags/maps/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Copy Go Maps with maps.Clone Without Sharing Top-Level State</title>
      <link>https://nalar.dev/copy-go-maps-with-maps-clone-without-sharing-top-level-state/</link>
      <pubDate>Thu, 10 Sep 2026 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/copy-go-maps-with-maps-clone-without-sharing-top-level-state/</guid>
      <description>&lt;p&gt;Copying a Go map is easy to get subtly wrong. Assigning one map variable to another doesn&amp;rsquo;t duplicate the map, so a write through either variable changes the same underlying map. Since Go 1.21, the standard library&amp;rsquo;s &lt;code&gt;maps.Clone&lt;/code&gt; function gives you a concise way to make a separate top-level map.&lt;/p&gt;&#xA;&lt;p&gt;There is one boundary worth understanding before using it: &lt;code&gt;maps.Clone&lt;/code&gt; is a &lt;strong&gt;shallow&lt;/strong&gt; clone. Adding, deleting, or replacing entries in the clone won&amp;rsquo;t change the original map, but nested maps, slices, pointers, and other reference-bearing values can still refer to the same underlying data.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
