inflateRaw failed in golang "compress/flate"
suconghou opened this issue · comments
suconghou commented
compress by golang
main.go
package main
import (
"bytes"
"compress/flate"
"os"
)
func main() {
data, err := encode([]byte("hello,world!"))
if err != nil {
panic(err)
}
os.WriteFile("1.data", data, 0666)
}
func encode(data []byte) ([]byte, error) {
var buf = bytes.NewBuffer(nil)
var w, err = flate.NewWriter(buf, flate.DefaultCompression)
if err != nil {
return nil, err
}
defer w.Close()
_, err = w.Write(data)
if err != nil {
return nil, err
}
err = w.Flush()
return buf.Bytes(), err
}
decompress
// yarn add pako@2.0.3 // failed, log undefined
// yarn add pako@1.0.11 // ok
const fs = require('fs')
const pako = require('pako')
const result = fs.readFileSync('1.data')
const res = pako.inflateRaw(result, {to: 'string'});
console.info(res)
pako 1.0.11 is ok ,
but 2.0.3 failed
Vitaly Puzrin commented
- Sorry, can't help with golang.
- I don't see any 2.x specific things.