Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compress/flate: Python zlib.compress's output can not be decompressed by Go #30982

Closed
andyxning opened this issue Mar 21, 2019 · 1 comment
Closed

Comments

@andyxning
Copy link

andyxning commented Mar 21, 2019

The output of Python's zlib.compress can not be decompressed by Golang's compress/flate

import zlib
print zlib.compress('deflate')
func main(){
       compressedMsg := THE_OUTPUT_OF_ZLIB_COMPRESS
        fr := flate.NewReader(bytes.NewReader(compressedMsg))
        defer fr.Close()
        body, err := ioutil.ReadAll(fr)
        if err != nil {
                return nil, fmt.Errorf("error in decode deflate compressed message: %v", err)
        }

        fmt.Println(body)
}
@ianlancetaylor ianlancetaylor changed the title Python zlib.compress's output can not be decompressed by Golang compress/flate compress/flate: Python zlib.compress's output can not be decompressed by Go Mar 21, 2019
@ianlancetaylor
Copy link
Contributor

You want zlib.NewReader here, not flate.NewReader.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants