测试版本go1.4.2
resp, err := http.Get("http://example.com/") if resp != nil { defer resp.Body.Close() } if err != nil { fmt.Println("err: ", err) return } _, err = ioutil.ReadAll(resp.Body) //去掉这句,则主动关闭连接 ???从这里看到的解释: The orignal implementation for
resp.Body.Close()
also reads and discards the remaining