rasky / go-lzo

Native LZO implementation in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can't decompress LZO compressed in Python

maxtepkeev opened this issue · comments

Hi Giovanni,

I have a Python application that compresses data using python-lzo and then decompresses when needed in another part of application.

I'm currently porting decompressing part of the application to golang and for some reason when I'm trying to use your library it always throws LookBehindUnderrun error at me. Here is the code I'm using:

import (
    "bytes"
    "fmt"

    "github.com/rasky/go-lzo"
)

outData, err = lzo.Decompress1X(bytes.NewReader(inData), 0, 0)
if err != nil {
    fmt.Println(err)
}

Any ideas ?

Thanks in advance.

Figured it out, python-lzo adds a custom header with a length of 5 bytes, so you just have to skip it and everything will work, e.g.:

import (
    "bytes"
    "fmt"

    "github.com/rasky/go-lzo"
)

outData, err = lzo.Decompress1X(bytes.NewReader(inData[5:]), 0, 0)
if err != nil {
    fmt.Println(err)
}

Thanks for porting lzo to pure golang.