Documentation
¶
Overview ¶
Package lzip implements the lzip compressed format.
The package supports version 1 of the lzip format.
Example ¶
const text = "The quick brown fox jumps over the lazy dog."
opt := &lzip.WriterOptions{4 * 1024 * 1024}
var buf bytes.Buffer
writer, err := lzip.NewWriterOptions(&buf, opt)
if err != nil {
log.Fatal(err)
}
if _, err := io.WriteString(writer, text); err != nil {
log.Fatal(err)
}
if err := writer.Close(); err != nil {
log.Fatal(err)
}
reader, err := lzip.NewReader(&buf)
if err != nil {
log.Fatal(err)
}
if _, err := io.Copy(os.Stdout, reader); err != nil {
log.Fatal(err)
}
Output: The quick brown fox jumps over the lazy dog.
Index ¶
Examples ¶
Constants ¶
const DefaultDictSize = 1 << 23
DefaultDictSize is the default dictionary size, which is 8 MiB.
const MaxDictSize = 1 << 29
MaxDictSize is the maximum dictionary size, which is 512 MiB.
const MaxMemberSize = 1 << 51
MaxMemberSize is the maximum member size, which is 2 PiB.
const MinDictSize = lzma.MinDictCap
MinDictSize is the minimum dictionary size, which is 4 KiB.
Variables ¶
var ErrInvalidMagic = errors.New("lzip: invalid magic number")
ErrInvalidMagic represents an error due to the magic number was invalid.
Functions ¶
This section is empty.
Types ¶
type DictSizeTooLargeError ¶ added in v0.3.0
type DictSizeTooLargeError struct {
// DictSize represents the obtained dictionary size.
DictSize uint32
}
DictSizeTooLargeError represents an error due to the dictionary size was larger than 512 MiB.
func (*DictSizeTooLargeError) Error ¶ added in v0.3.0
func (e *DictSizeTooLargeError) Error() string
Error returns a string representation of a DictSizeTooLargeError.
type DictSizeTooSmallError ¶ added in v0.3.0
type DictSizeTooSmallError struct {
// DictSize represents the obtained dictionary size.
DictSize uint32
}
DictSizeTooSmallError represents an error due to the dictionary size was smaller than 4 KiB.
func (*DictSizeTooSmallError) Error ¶ added in v0.3.0
func (e *DictSizeTooSmallError) Error() string
Error returns a string representation of a DictSizeTooSmallError.
type InvalidCRCError ¶ added in v0.3.0
type InvalidCRCError struct {
// CRC represents the obtained CRC.
CRC uint32
}
InvalidCRCError represents an error due to a CRC of the original uncompressed data mismatched.
func (*InvalidCRCError) Error ¶ added in v0.3.0
func (e *InvalidCRCError) Error() string
Error returns a string representation of an InvalidCRCError.
type InvalidDataSizeError ¶ added in v0.3.0
type InvalidDataSizeError struct {
// DataSize represents the obtained data size.
DataSize uint64
}
InvalidDataSizeError represents an error due to the size of the original uncompressed data stored in the trailer and the actual size of it mismatched.
func (*InvalidDataSizeError) Error ¶ added in v0.3.0
func (e *InvalidDataSizeError) Error() string
Error returns a string representation of an InvalidDataSizeError.
type InvalidMemberSizeError ¶ added in v0.3.0
type InvalidMemberSizeError struct {
// MemberSize represents the obtained member size.
MemberSize uint64
}
InvalidMemberSizeError represents an error due to the total size of the member stored in the trailer and the actual total size of it mismatched.
func (*InvalidMemberSizeError) Error ¶ added in v0.3.0
func (e *InvalidMemberSizeError) Error() string
Error returns a string representation of an InvalidMemberSizeError.
type MemberSizeTooLargeError ¶ added in v0.3.0
type MemberSizeTooLargeError struct {
// MemberSize represents the obtained member size.
MemberSize uint64
}
MemberSizeTooLargeError represents an error due to the member size was larger than 2 PiB.
func (*MemberSizeTooLargeError) Error ¶ added in v0.3.0
func (e *MemberSizeTooLargeError) Error() string
Error returns a string representation of a MemberSizeTooLargeError.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is an io.Reader that can be read to retrieve uncompressed data from a lzip-format compressed file.
Example ¶
file, err := os.Open("testdata/fox.lz")
if err != nil {
log.Fatal(err)
}
defer func() {
if err := file.Close(); err != nil {
log.Fatal(err)
}
}()
reader, err := lzip.NewReader(bufio.NewReader(file))
if err != nil {
log.Print(err)
return
}
if _, err := io.Copy(os.Stdout, reader); err != nil {
log.Print(err)
return
}
Output: The quick brown fox jumps over the lazy dog.
type UnknownVersionError ¶ added in v0.3.0
type UnknownVersionError struct {
// Version represents the obtained version number.
Version byte
}
UnknownVersionError represents an error due to the version number stored in the header was not recognized by this package.
func (*UnknownVersionError) Error ¶ added in v0.3.0
func (e *UnknownVersionError) Error() string
Error returns a string representation of an UnknownVersionError.
type UnsupportedVersionError ¶ added in v0.3.0
type UnsupportedVersionError struct {
// Version represents the obtained version number.
Version byte
}
UnsupportedVersionError represents an error due to the version number stored in the header indicated the lzip format which is not supported by this package.
func (*UnsupportedVersionError) Error ¶ added in v0.3.0
func (e *UnsupportedVersionError) Error() string
Error returns a string representation of an UnsupportedVersionError.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is an io.WriteCloser that can be written to retrieve a lzip-format compressed file from data.
Example ¶
const text = "The quick brown fox jumps over the lazy dog."
var buf bytes.Buffer
writer := lzip.NewWriter(&buf)
if _, err := io.WriteString(writer, text); err != nil {
log.Fatal(err)
}
if err := writer.Close(); err != nil {
log.Fatal(err)
}
func NewWriter ¶
NewWriter creates a new Writer writing the given writer.
This uses the default parameters.
func NewWriterOptions ¶
func NewWriterOptions(w io.Writer, opt *WriterOptions) (*Writer, error)
NewWriterOptions creates a new Writer writing the given writer.
This uses the given WriterOptions.
type WriterOptions ¶
type WriterOptions struct {
// DictSize sets the dictionary size.
DictSize uint32
}
WriterOptions configures Writer.
func (*WriterOptions) Verify ¶
func (o *WriterOptions) Verify() error
Verify checks if WriterOptions is valid.