title: Can you type assert an anonymous struct?
body: <p>I want to do something like this:</p>
  
  <pre><code>type Struct1 struct {
      var1 int
  }
  
  type i interface {
      display()
  }
  
  func (s Struct1) display() {
      fmt.Println(s.var1)
  }
  
  func check(i interface{}) {
      i.(Struct1).display()
  }
  
  func main() {
      data := struct {
          int
      }{
          2,
      }
  
      check(interface{}(data))
  }
  </code></pre>
  
  <p>I have a function in an external dependency that accepts and returns interface{} type. That function type asserts a struct(let's say Struct1). The struct has fields that are not exported to I cannot create an instance of it to pass to the function. I know what fields it has, their names and types. Is it possible to send data not of type Struct1 that can be asserted to become Struct1 type.</p>