On Mon, 2021-06-21 at 16:53 -0500, Steven Penny wrote: > > Again, the idiom is, if you get an `io.Closer`, `Close` should be > > called once > > you're done with it. > > Thanks for the responses, but I am not convinced. Other than "its > just good > practice", I havent seen a single concrete example where not closing > a gzip > reader would cause a problem. Until that happens, I am just going to > stop doing > it in my code. > > As far as Im concerned, gzip Close seems about as useful as > io.NopCloser. Again, > if I am wrong on this, I certainly want to know it, but at this > moment it doesnt > seem that I am.
The relevant code is in compress/flate. There you can see that it is possible for the flate decompressor to advance without returning an error, but storing the error in its err field. This is then returned when the Close method is called. This particular case won't be seen when a flate stream is read to completion, but if you partially read a stream and encounter an error without closing you could see different behaviours. Dan -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/858087d9b1fe39c8e2949559b8677e21b1f8fbb1.camel%40kortschak.io.