Hi ,
Has anyone tried compressing > ~2.5 GB of data using golang.
The following function compresses files. Files less than ~2.5 GB are
successful with any data loss. Files greater than ~2.5 are getting
compressed but the API trims section of the data at the last
Any inputs are welcome!!!
func compressFile(filename string, outputFile string) {
fmt.Println("Compresssng file " + filename)
if filename == "" {
os.Exit(1)
}
rawfile, err := os.Open(filename)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
defer rawfile.Close()
// calculate the buffer size for rawfile
info, _ := rawfile.Stat()
var size int64 = info.Size()
rawbytes := make([]byte, size)
// read rawfile content into buffer
buffer := bufio.NewReader(rawfile)
_, err = buffer.Read(rawbytes)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
var buf bytes.Buffer
writer := gzip.NewWriter(&buf)
writer.Write(rawbytes)
writer.Close()
err = ioutil.WriteFile(outputFile, buf.Bytes(), info.Mode())
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println("compresssng file " + filename + " complete")
}
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.