title: Unable to Unmarshall to types.Struct with Protobuf
body: <p>I am working on a legacy Go app that it's driving me crazy in terms of type definition.</p>
  <p>At some point I need to return a value with the value <code>types.Struct</code> (from <code>github.com/gogo/protobuf/types</code>).</p>
  <p>Here is the signature for the function:</p>
  <pre><code>GetDeviceConfig(ctx context.Context, in *DeviceID, opts ...grpc.CallOption) (*types.Struct, error)
  
  </code></pre>
  <p>I'm getting the value from a Postgres database (with GORM) using a string column called &quot;config&quot;. It could be any type of JSON.</p>
  <p>Just an example:</p>
  <pre><code>{&quot;fields&quot;:{&quot;A&quot;:{&quot;Kind&quot;:{&quot;string_value&quot;:&quot;B&quot;}},&quot;C&quot;:{&quot;Kind&quot;:{&quot;string_value&quot;:&quot;D&quot;}}}}
  </code></pre>
  <p>When I try to unmarshall to a <code>map[string]interface{}</code> it works like a charm:</p>
  <pre><code>err := client.DB.Where(&quot;id = ?&quot;, id, 0).First(&amp;device).Error
      if err != nil &amp;&amp; err != gorm.ErrRecordNotFound {
          return nil, err
      }
  
      var dat map[string]interface{}
  
      if err := json.Unmarshal([]byte(device.Config), &amp;dat); err != nil {
          panic(err)
      }
  </code></pre>
  <p>but I need to conver it to <code>types.Struct</code> (valid protobuf signature that cannot be changed). My best guess was something like this:</p>
  <pre><code>// convert json to struct
      s := types.Struct{}
      if err := json.Unmarshal([]byte(device.Config), &amp;s); err != nil {
          panic(err)
      }
      // fmt.Println(s)
  </code></pre>
  <p>but <code>s</code> is empty. No data is populated.</p>
  <p>Any help?</p>