Re: [go-nuts] Re: http response issue with leaking handles

2016-07-29 Thread James Bardin
On Fri, Jul 29, 2016 at 2:01 AM, wrote: > Thanks James, are there any golang tools which could have caught this > issue. I know go vet didnt. Caught the issue of using the first odd pattern for closing the response Body? There's no tool that can detect general logic errors in your program, but

Re: [go-nuts] Re: http response issue with leaking handles

2016-07-28 Thread krmayankk
Thanks James, are there any golang tools which could have caught this issue. I know go vet didnt. On Thursday, July 28, 2016 at 1:36:04 PM UTC-7, James Bardin wrote: > > > > On Thursday, July 28, 2016 at 2:34:24 PM UTC-4, krma...@gmail.com wrote: >> >> WHere is this documented in "On error, any

Re: [go-nuts] Re: http response issue with leaking handles

2016-07-28 Thread James Bardin
On Thursday, July 28, 2016 at 2:34:24 PM UTC-4, krma...@gmail.com wrote: > > WHere is this documented in "On error, any Response can be ignored. A > non-nil Response with a non-nil error only occurs when CheckRedirect fails, > and even then the returned Response.Body is already closed" > > I am

Re: [go-nuts] Re: http response issue with leaking handles

2016-07-28 Thread krmayankk
WHere is this documented in "On error, any Response can be ignored. A non-nil Response with a non-nil error only occurs when CheckRedirect fails, and even then the returned Response.Body is already closed" I am interested in looking at it. I didnt find it here https://golang.org/pkg/net/http/

Re: [go-nuts] Re: http response issue with leaking handles

2016-07-28 Thread James Bardin
On Thu, Jul 28, 2016 at 11:08 AM, Ian Davis wrote: > Great. Very clear. > > To those looking for this: it's a new comment added after 1.6.2 > Thanks, forgot I was on master. Yes, this was implied by the error handling example in the docs, but now is much more explicit. -- You received this me

Re: [go-nuts] Re: http response issue with leaking handles

2016-07-28 Thread Ian Davis
On Thu, Jul 28, 2016, at 03:50 PM, James Bardin wrote: > > On Thu, Jul 28, 2016 at 10:39 AM, Ian Davis wrote: >> Is it? The http package only says: >> >> "When err is nil, resp always contains a non-nil resp.Body. Caller >> should close resp.Body when done reading from it." >> >> It doesn't say

Re: [go-nuts] Re: http response issue with leaking handles

2016-07-28 Thread James Bardin
On Thu, Jul 28, 2016 at 10:39 AM, Ian Davis wrote: > Is it? The http package only says: > > "When err is nil, resp always contains a non-nil resp.Body. Caller should > close resp.Body when done reading from it." > > It doesn't say anything about the case where err != nil > > On error, any Respon

Re: [go-nuts] Re: http response issue with leaking handles

2016-07-28 Thread Ian Davis
On Thu, Jul 28, 2016, at 03:14 PM, James Bardin wrote: > > > 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

[go-nuts] Re: http response issue with leaking handles

2016-07-28 Thread James Bardin
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. re