Gzip: unexpected EOF

2,138 views
Skip to first unread message

bsr

unread,
Mar 14, 2013, 2:13:10 AM3/14/13
to golan...@googlegroups.com
I get "ERROR: unexpected EOF" while using gzip.


Also please comment on any leak (not sure NopCloser is necessary)

Andrew Gerrand

unread,
Mar 14, 2013, 2:19:19 AM3/14/13
to bsr, golang-nuts
When you:

defer gz.Close()

you defer the call to Close until the end of the main function, but you start reading from the buffer before that happens.

The Close method on a gzip.Writer writes out the rest of the gzip stream.

You must close the writer before reading the stream back.


Andrew


--
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...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

bsr

unread,
Mar 14, 2013, 2:44:09 AM3/14/13
to golan...@googlegroups.com, bsr
thanks Andrew for explaining the cause.

David DENG

unread,
Mar 14, 2013, 6:59:38 AM3/14/13
to golan...@googlegroups.com, bsr
Or make part of the line in an anonymous function like this:


David
Reply all
Reply to author
Forward
0 new messages