zlib

package
v0.0.0-...-90c9d3a Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2010 License: BSD-3-Clause, GooglePatentClause Imports: 6 Imported by: 0

Documentation

Overview

The zlib package implements reading and writing of zlib format compressed data, as specified in RFC 1950.

The implementation provides filters that uncompress during reading and compress during writing. For example, to write compressed data to a buffer:

var b bytes.Buffer
w, err := zlib.NewDeflater(&b)
w.Write([]byte("hello, world\n"))
w.Close()

and to read that data back:

r, err := zlib.NewInflater(&b)
io.Copy(os.Stdout, r)
r.Close()

Index

Constants

View Source
const (
	NoCompression      = flate.NoCompression
	BestSpeed          = flate.BestSpeed
	BestCompression    = flate.BestCompression
	DefaultCompression = flate.DefaultCompression
)

These constants are copied from the flate package, so that code that imports "compress/zlib" does not also have to import "compress/flate".

Variables

View Source
var ChecksumError os.Error = os.ErrorString("zlib checksum error")
View Source
var HeaderError os.Error = os.ErrorString("invalid zlib header")
View Source
var UnsupportedError os.Error = os.ErrorString("unsupported zlib format")

Functions

func NewDeflater

func NewDeflater(w io.Writer) (io.WriteCloser, os.Error)

NewDeflater calls NewDeflaterLevel with the default compression level.

func NewDeflaterLevel

func NewDeflaterLevel(w io.Writer, level int) (io.WriteCloser, os.Error)

NewDeflaterLevel creates a new io.WriteCloser that satisfies writes by compressing data written to w. It is the caller's responsibility to call Close on the WriteCloser when done. level is the compression level, which can be DefaultCompression, NoCompression, or any integer value between BestSpeed and BestCompression (inclusive).

func NewInflater

func NewInflater(r io.Reader) (io.ReadCloser, os.Error)

NewInflater creates a new io.ReadCloser that satisfies reads by decompressing data read from r. The implementation buffers input and may read more data than necessary from r. It is the caller's responsibility to call Close on the ReadCloser when done.

Types

This section is empty.

Notes

Bugs

  • The zlib package does not implement the FDICT flag.

Jump to

Keyboard shortcuts

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