title: Imported struct to be used as anonymous field
body: <p>So I'm trying to write a few Go files such that there is a public facing package and an internal package.</p>
  
  <p>In the public facing package, there is a struct that is nearly identical (missing one field) to an internal struct.</p>
  
  <p>I thought of using an anonymous field in the internal struct, but it doesn't seem to play nicely.</p>
  
  <hr>
  
  <p>Example:</p>
  
  <p>public/public.go:</p>
  
  <pre><code>package public
  
  type PublicStruct struct {
      Field1 bool `json:"fetchStats"`
  }
  </code></pre>
  
  <p>data/data.go</p>
  
  <pre><code>package data
  
  import publicData "public"
  
  type InternalStruct struct {
      publicData.PublicStruct
      Field2 bool `json:"includeHidden:`
  }
  </code></pre>
  
  <p>filter/filter.go:</p>
  
  <pre><code>package filter
  
  import "data"
  
  func test() {
      tmp := data.InternalStruct{Field1: true, Field2: false}
  }
  </code></pre>
  
  <p>main.go:</p>
  
  <pre><code>package main
  
  import "filter"
  import "data"
  
  func main() {
      var tmp data.InternalStruct
      tmp.Field1 = true
      tmp.Field2 = true
      filter.Test()
  }
  </code></pre>
  
  <hr>
  
  <p>Expected: no issues</p>
  
  <p>Result: <code>filter/filter.go:6: unknown data.InternalStruct field 'Field1' in struct literal</code></p>
  
  <hr>
  
  <p>Why does this not work and what should I do to make it work (I'm currently using the duplicate parameters in both structs approach)?</p>
  
  <hr>
  
  <p>PS: I don't know how to test this in go playground since it involves multiple files.</p>