Thanks, the io.copy resolved the issue.
Thanks & Regards
On Thu, Feb 16, 2017 at 2:51 AM, Dave Cheney <d...@cheney.net> wrote:
> Or use https://godoc.org/io/ioutil#ReadFile
> By really you don't need to buffer all the data in memory, io.Copy will do
> that for you
> in, err := os.Open(input)
> defer in.Close()
> out, err := os.Create(output)
> gz := gzip.New.Writer(out)
> _, err = io.Copy(gz, in)
> err = gz.Close()
> err = out.Close()
> On Thursday, 16 February 2017 06:05:51 UTC+11, howar...@gmail.com wrote:
>> While it is not clear from the Buffer documentation, the Reader
>> *interface* documentation (which Buffer.Read implements implicitly) does
>> state "up to len(p) bytes." You are ignoring how many bytes it read and
>> assuming that the one read is reading the whole file. I am not sure that
>> this is guaranteed with Buffer.Read.
>> I would suggest you try to adhere to the Reader interface's documented
>> behavior, and continue to call Read until you get EOF, and process the n
>> returned bytes each time. Doing this would also make it easier to then move
>> a step further and drop your buffer size to something sensible, instead of
>> attempting to read the entire 2.5G file into memory before compressing.
You received this message because you are subscribed to the Google Groups
To unsubscribe from this group and stop receiving emails from it, send an email
For more options, visit https://groups.google.com/d/optout.