func (c *LZMA) Encode(decodedData []byte) ([]byte, error) {
	wc := lzma.WriterConfig{
		SizeInHeader: true,
		Size:         int64(len(decodedData)),
		EOSMarker:    false,
		Properties:   &lzma.Properties{LC: 3, LP: 0, PB: 2},
		DictCap:      1 << lzmaDictCapExps[compressionLevel],
	}
	if err := wc.Verify(); err != nil {
		return nil, err
	}
	buf := &bytes.Buffer{}
	w, err := wc.NewWriter(buf)
	if err != nil {
		return nil, err
	}
	if _, err := io.Copy(w, bytes.NewBuffer(decodedData)); err != nil {
		return nil, err
	}
	if err := w.Close(); err != nil {
		return nil, err
	}
	return buf.Bytes(), nil
}
Encode encodes a byte slice with LZMA.
package compression
import (
	"bytes"
	"io"
	"io/ioutil"
	"github.com/ulikunitz/xz/lzma"
)
var lzmaDictCapExps = []uint{18, 20, 21, 22, 22, 23, 23, 24, 25, 26}
var compressionLevel = 7
type LZMA struct{}
func (c *LZMA) Name() string {
	return "LZMA"
}
func (c *LZMA) Decode(encodedData []byte) ([]byte, error) {
	r, err := lzma.NewReader(bytes.NewBuffer(encodedData))
	if err != nil {
		return nil, err
	}
	return ioutil.ReadAll(r)
}