On Thursday, July 28, 2016 at 2:40:38 AM UTC-4, krma...@gmail.com wrote:
>
> resp, err := http.Get("https://api.ipify.org?format=json";) if resp != nil 
> { defer resp.Body.Close() }
>
>
This is incorrect. There's no guarantee that a non-nil Response contains a 
non-nil Body after an error.
 

resp, err := http.Get("https://api.ipify.org?format=json";) if err != nil { 
> fmt.Println(err) return } defer resp.Body.Close()//ok, most of the time 
> :-)
>


No, this is correct "all of the time" , and is documented as such in the 
http package.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to