title: Golang assign value to deep nested structure
body: <p>I'm learning Go and so far really enjoying it. Coming from a JS background, there are certain patterns and best practices that I'm still discovering.</p>
  
  <p>What would be the best way to get and assign a value to a deeply nested object in Go using a Object path? For example, in JS it could be done like this...</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var children = [{children:[{children:[{a:1}]}]}]
  var child = "0.children.0.children.0".split('.').reduce((c, p) =&gt; c[p], children)
  child.a = 2
  console.log(children[0].children[0].children[0].a)</code></pre>
  </div>
  </div>
  </p>