lzo

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 4 Imported by: 10 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-lzo

This repository provides an implementation of the LZO1X decompression algorithm in Go. The implementation is derived from the Linux kernel documentation for the LZO stream format and the implementation from lzokay project (MIT licensed). It includes a Reader for streaming decompressed data and a standalone Decompress function for use with byte slices.

To use this library:

go get github.com/anchore/go-lzo

Documentation

Overview

Package lzo is a direct implementation of the LZO decompression algorithm in Go using the following sources as references:

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLookbehindOverrun   = errors.New("lzo: lookbehind overrun")
	ErrOutputOverrun       = errors.New("lzo: output overrun")
	ErrInputOverrun        = errors.New("lzo: input overrun")
	ErrDecompressionFailed = errors.New("lzo: error during decompression")
	ErrInputNotConsumed    = errors.New("lzo: input not fully consumed")
)

Functions

func Decompress

func Decompress(srcBytes, dstBytes []byte) (outSize int, err error)

Decompress the given LZO1X compressed data to the destination buffer.

Here's a summary of the state machine:

Instruction    Bits        Description
-------------- ------------ -------------------------------------------------
M1 (short)     0x00..0x0F  copy 2-3 bytes based on previous literal state
M1 (long)      0x00..0x0F  when state==0, long literal run (>=4 bytes)
M2             0x40..0xFF  copy 3-8 bytes within 2kB distance
M3             0x20..0x3F  copy small block within 16kB distance
M4             0x10..0x1F  copy block within 16..48kB, end-of-stream if distance==16384

Types

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader implements io.Reader for LZO-compressed data

func NewReader

func NewReader(src io.Reader) *Reader

NewReader creates a new LZO reader with default 64KB buffer

func NewReaderSize

func NewReaderSize(src io.Reader, blockSize int) *Reader

NewReaderSize creates a new LZO reader with specified buffer size

func (*Reader) Close

func (r *Reader) Close() error

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址