title: how handle error in http.Get in function
body: <p>I have a problem whith this function:</p>
  
  <pre><code>func execute(query Query) (goreq.Response, error) {
  
      res, err := goreq.Request{
          Uri:         "http://path/to/host",
          QueryString: query,
          Accept:      "application/json",
          UserAgent:   "XXXGoClient/1.0",
          Timeout:     2000 * time.Millisecond,
          Compression: goreq.Gzip(),
          //ShowDebug:   true,
      }.Do()
  
      return *res, err
  }
  </code></pre>
  
  <p>i am getting <code>panic: runtime error: invalid memory address or nil pointer dereference</code> when a error in http request ocurrs.</p>
  
  <p>I know that i would check for something like this:</p>
  
  <pre><code>if err != nil {
      // do somthing here
  }
  </code></pre>
  
  <p>but i dont know what i must to do, for example this:</p>
  
  <pre><code>if err != nil {
      return
  }
  </code></pre>
  
  <p>i get <code>./main.go:113: not enough arguments to return</code></p>