title: Golang return child struct in place of parent like in c++
body: <p>I am trying to have a generic function that can return various multiple child objects. The idea is to be able to return those in a request json body.</p>
  
  <p>The code is as follows</p>
  
  <pre><code>GenericType struct {
      V1 string `json:"v1"`
      V2 string `json:"v2"`
  }
  
  SubType struct {
      GenericType
      V3 string `json:"v3"`
  }
  
  func TestFunc() GenericType {
      val := SubType{
          GenericType: GenericType{
              V1: "a",
              V2: "b",
          },
          V3: "c",
      }
      return val
  }
  </code></pre>
  
  <p>The error is </p>
  
  <pre><code>cannot use val (type SubType) as type GenericType in return argument
  </code></pre>
  
  <p>Is it possible to return a descendant struct in a parent pointer without losing the fields of that descendant struct and then return it as a JSON object in response body?</p>