title: Using composition vs embedding in yaml model structs
body: <p>I have the following <code>yaml</code> file</p>
  <pre class="lang-yaml prettyprint-override"><code>apiVersion: helm.toolkit.fluxcd.io/v2beta1
  kind: HelmRelease
  metadata:
    name: myapp
    namespace: mynamespace
  </code></pre>
  <p>And using the following construct to unmarshal it</p>
  <pre class="lang-golang prettyprint-override"><code>type hr struct {
      APIVersion string `yaml:&quot;apiVersion&quot;`
      Kind       string `yaml:&quot;kind&quot;`
      Metadata   `yaml:&quot;metadata&quot;`
  }
  
  type Metadata struct {
      Name      string `yaml:&quot;name&quot;`
      Namespace string `yaml:&quot;namespace&quot;`
  }
  </code></pre>
  <p>My question is whether there is a practical difference in using embedding vs composision in the <code>hr</code> struct, i.e instead if declaring it as above, providing a name in the <code>Metadata</code> field, as in</p>
  <pre class="lang-golang prettyprint-override"><code>type hr struct {
      APIVersion string   `yaml:&quot;apiVersion&quot;`
      Kind       string   `yaml:&quot;kind&quot;`
      MD         Metadata `yaml:&quot;metadata&quot;`
  }
  </code></pre>
  <p>Is any of the two approaches preferred over the other when it comes to <code>yaml</code> unmarshalling?</p>
  <p>(both methods seem to be working fine btw in the actual unmarshalling)</p>