title: Resolving an invalid memory address or nil pointer dereference
body: <p>Banging my head on this one. I can't get an HTTP Response to assign to a struct.</p>
  
  <p>I have my structs set up like so:</p>
  
  <pre><code>type DataConnect struct {
      Response *Response
  }
  
  type Response struct {
      response []byte
      errors   []string
  }
  </code></pre>
  
  <p>Then the function in question is laid out like so (trimmed for readability):</p>
  
  <pre><code>137 func (d *DataConnect) send() bool {
  
      ...
  
  154    out, err := ioutil.ReadAll(resp.Body)
  155    if err != nil {
  156        fmt.Println(err)
  157    }
  158
  159    fmt.Printf("%s\n", out) // THIS WORKS
  160    d.Response.response = out // THIS DOES NOT WORK
  161 }
  </code></pre>
  
  <p>Doing that results in the following error:</p>
  
  <pre><code>panic: runtime error: invalid memory address or nil pointer dereference
  [signal 0xb code=0x1 addr=0x0 pc=0x36532]
  
  goroutine 1 [running]:
  github.com/DataConnect.(*DataConnect).send(0xc2000af4a0, 0x232a00)
  github.com/DataConnect/DataConnect.go:160 +0xc22
  </code></pre>
  
  <p>Now if I change <code>DataConnect.Response.response</code> to type <code>interface{}</code> I can save successfully to it, however I need it in <code>[]byte</code> as later I will be doing a json.Unmarshal on the content.</p>
  
  <p>Does anybody have any idea why this isn't working?</p>