title: Goroutine gives error
body: <p>I am trying to poll a website multiple times but I get:</p>
  
  <blockquote>
    <p>panic: runtime error: invalid memory address or nil pointer dereference</p>
    
    <p>[signal 0xb code=0x1 addr=0x38 pc=0x400cca]</p>
  </blockquote>
  
  <pre><code>package main
  
  import (
      "fmt"
      "net/http"
  )
  
  var urls = []string{
      "http://site-centos-64:8080/examples/abc1.jsp",
  }
  
  type HttpResponse struct {
      url      string
      response *http.Response
      err      error
  }
  var ch = make(chan *HttpResponse, 1000) // buffered
  
  func abc(i int){
          for _, url := range urls {
                  resp, err := http.Get(url)
                  resp.Body.Close()
                  ch &lt;- &amp;HttpResponse{url, resp, err}
          }
  }
  func asyncHttpGets(urls []string) []*HttpResponse {
      responses := []*HttpResponse{}
      for i:=0;i&lt;1000;i++{
          go abc(i)
      }
      for {
          select {
          case r := &lt;-ch:
              responses = append(responses, r)
              if len(responses) == 1000 {
                  return responses
              }
  
          }
      }
  
      return responses
  
  }
  
  func main() {
      results := asyncHttpGets(urls)
      for _, result := range results {
          fmt.Printf("%s status: %s\n", result.url,
              result.response.Status)
      }
  }
  </code></pre>
  
  <p>Works absolutely fine when I do it for 500 times.</p>