title: Golang elegantly JSON decode different structures
body: <p>I have different structures that share a field and I need to decode a JSON file into its corresponding structure in Go. </p>
  
  <p>Example:</p>
  
  <pre><code>type Dog struct {
    AnimalType string //will always be "dog"
    BarkLoudnessLevel int
  }
  
  type Cat struct {
    AnimalType string //will always be "cat"
    SleepsAtNight bool
  }
  </code></pre>
  
  <p>If I am receiving one of these structures as a JSON string, what would be the most elegant way of parsing it into its proper structure?</p>