title: Error making a []map[string]interface{} with for loop -> panic: assignment to entry in nil map
body: <p>Im trying to build a []map[string]interface{} using a loop like so:</p>
  
  <pre><code>package main
  
  import (
      "encoding/json"
      "fmt"
  )
  
  type People []struct {
      Name string `json:"name"`
      Age  int    `json:"age"`
  }
  
  func main() {
      resp := `[{"name":"Test","age":15}, {"name":"Test2","age":25}]`
      data := &amp;People{}
      _ = json.Unmarshal([]byte(resp), data)
      m := make([]map[string]interface{}, len(*data))
      for k, v := range *data {
          m[k]["Name"] = v.Name
          m[k]["Age"] = v.Age
      }
      fmt.Println(m)
      fmt.Printf("%T", m)
  }
  
  </code></pre>
  
  <p>But Im always getting this error:</p>
  
  <blockquote>
    <p>panic: assignment to entry in nil map</p>
    
    <p>goroutine 1 [running]: main.main()    /tmp/sandbox300360207/prog.go:19
    +0x17a</p>
  </blockquote>
  
  <p>I cant use <code>m := make(People, len(*data))</code> and <code>m[k].Name = v.Name</code> because I need the type to be <code>[]map[string]interface{}</code> and not main.People</p>
  
  <p>I also tried this:</p>
  
  <pre><code>func main() {
      resp := `[{"name":"Test","age":15}, {"name":"Test2","age":25}]`
      data := &amp;People{}
      _ = json.Unmarshal([]byte(resp), data)
      m := make([]map[string]interface{}, len(*data))
      for k, v := range *data {
          m[k] = map[string]interface{"Name": v.Name, "Age": v.Age}
      }
      fmt.Println(m)
      fmt.Printf("%T", m)
  }
  </code></pre>
  
  <p>But got this error: </p>
  
  <blockquote>
    <p>./prog.go:19:31: syntax error: unexpected literal "Name", expecting
    method or interface name</p>
  </blockquote>