<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Pointers on ErrorVault — Developer Error Code Dictionary</title>
    <link>https://errorvault.dev/tags/pointers/</link>
    <description>Recent content in Pointers on ErrorVault — Developer Error Code Dictionary</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 01 Jul 2026 11:17:00 +0800</lastBuildDate>
    <atom:link href="https://errorvault.dev/tags/pointers/feed.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Fix go-cannot-assign-to: Cannot assign to struct field in map or range variable</title>
      <link>https://errorvault.dev/golang/golang-go-cannot-assign-to-struct-field-map-range/</link>
      <pubDate>Wed, 01 Jul 2026 11:17:00 +0800</pubDate>
      <guid>https://errorvault.dev/golang/golang-go-cannot-assign-to-struct-field-map-range/</guid>
      <description>&lt;h2 id=&#34;1-symptoms&#34;&gt;1. Symptoms&lt;/h2&gt;&#xA;&lt;p&gt;The &lt;code&gt;go-cannot-assign-to&lt;/code&gt; error manifests during compilation when attempting to modify struct fields obtained from map indexing or range iteration. The Go compiler emits messages like:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#282a36;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-gdscript3&#34; data-lang=&#34;gdscript3&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ff79c6&#34;&gt;./&lt;/span&gt;main&lt;span style=&#34;color:#ff79c6&#34;&gt;.&lt;/span&gt;go:&lt;span style=&#34;color:#bd93f9&#34;&gt;15&lt;/span&gt;:&lt;span style=&#34;color:#bd93f9&#34;&gt;9&lt;/span&gt;: cannot assign to struct field user&lt;span style=&#34;color:#ff79c6&#34;&gt;.&lt;/span&gt;Name &lt;span style=&#34;color:#ff79c6&#34;&gt;in&lt;/span&gt; map&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#ff79c6&#34;&gt;./&lt;/span&gt;main&lt;span style=&#34;color:#ff79c6&#34;&gt;.&lt;/span&gt;go:&lt;span style=&#34;color:#bd93f9&#34;&gt;20&lt;/span&gt;:&lt;span style=&#34;color:#bd93f9&#34;&gt;12&lt;/span&gt;: cannot assign to struct field item&lt;span style=&#34;color:#ff79c6&#34;&gt;.&lt;/span&gt;Value &lt;span style=&#34;color:#ff79c6&#34;&gt;in&lt;/span&gt; &lt;span style=&#34;color:#8be9fd;font-style:italic&#34;&gt;range&lt;/span&gt; iterate variable&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Typical shell output from &lt;code&gt;go build&lt;/code&gt; or &lt;code&gt;go run&lt;/code&gt; halts with exit code 1, preventing execution. Indicators include failed builds in CI/CD pipelines, IDE red squiggles under assignment operators (&lt;code&gt;=&lt;/code&gt;), and hover tooltips citing &amp;ldquo;non-name&amp;rdquo; or &amp;ldquo;cannot assign to&amp;rdquo; for expressions like &lt;code&gt;m[key].Field = newValue&lt;/code&gt; or &lt;code&gt;for _, v := range slice { v.Field = updated }&lt;/code&gt;. This error blocks code that iterates over collections intending to mutate elements, common in data processing, configuration updates, or graph traversals. No runtime symptoms occur since compilation fails outright.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
