title: Golang and JSON with array of struct
body: <p>I would like to create a JSON of a <code>GatewayInfo</code> where the type are defined like this:</p>
  
  <pre><code>type SpanInfo struct {
      imsi string
      network string
      network_status string
      signal_quality int
      slot int
      state string
  }
  
  type GatewayInfo []SpanInfo
  </code></pre>
  
  <p>The gateway information is created with:</p>
  
  <pre><code>var gatewayInfo = make(GatewayInfo, nb_spans)
  </code></pre>
  
  <p>To create the JSON, I use the <code>json.Marshal</code> function:</p>
  
  <pre><code>gatewayInfo := getGatewayInfo(spans)
  log.Printf("Polling content: %s\n", gatewayInfo)
  
  jsonInfo, _ := json.Marshal(gatewayInfo)
  log.Printf("jsonInfo: %s\n", jsonInfo)
  </code></pre>
  
  <p>Unfortunately the result is not what I was expecting:</p>
  
  <pre><code>2015/02/09 13:48:26 Polling content: [{652020105829193 20801 Registered (Roaming) %!s(int=17) %!s(int=2) } {652020105829194 20801 Registered (Roaming) %!s(int=16) %!s(int=3) } {652020105829192 20801 Registered (Roaming) %!s(int=19) %!s(int=1) } {652020105829197 20801 Registered (Roaming) %!s(int=19) %!s(int=4) }]
  2015/02/09 13:48:26 jsonInfo: [{},{},{},{}]
  </code></pre>
  
  <p>As we can see, the <code>GatewayInfo</code> instance has the <code>SpanInfo</code>, but in the JSON I have empty <code>SpanInfo</code>.</p>