title: XML and JSON tags for a Golang struct?
body: <p>I have an application that can output as JSON or XML depending on the HTTP request headers. I can achieve the correct output for either by adding the correct tags to the structs I'm using, but I can't figure out how to specify the tags for both JSON and XML.</p>
  
  <p>For example, this serializes to correct XML:</p>
  
  <pre><code>type Foo struct {
      Id          int64       `xml:"id,attr"`
      Version     int16       `xml:"version,attr"`
  }
  </code></pre>
  
  <p>...and this generates correct JSON:</p>
  
  <pre><code>type Foo struct {
      Id          int64       `json:"id"`
      Version     int16       `json:"version"`
  }
  </code></pre>
  
  <p>...but this doesn't work for either:</p>
  
  <pre><code>type Foo struct {
      Id          int64       `xml:"id,attr",json:"id"`
      Version     int16       `xml:"version,attr",json:"version"`
  }
  </code></pre>