Just as a side note, you've got a mistake that has got me before too.
You need to check the error before doing the deferred close. :)
var client http.Client
resp, err := client.Get(url)
if err != nil {
...
}
defer resp.Body.Close()
If there has been an error, then there is no Body to close so you must
check first.
Cheers,
Andy
--
Andrew Chilton
e: chi...@appsattic.com
w: http://www.appsattic.com/
On 9 September 2011 07:47, barnex <a.vanst...@gmail.com> wrote:
> var client http.Client
> resp, err := client.Get(url)
> defer resp.Body.Close()
> if err != nil {
> ...
> }Just as a side note, you've got a mistake that has got me before too.
You need to check the error before doing the deferred close. :)var client http.Client
resp, err := client.Get(url)
if err != nil {
...
}
defer resp.Body.Close()If there has been an error, then there is no Body to close so you must
check first.