zreader

package module
v0.0.0-...-0540e75 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

ZReader

ZReader is a Go module that provides an io.ReadCloser for a variety of compression formats.

Documentation

Overview

Package zreader provides an io.ReadCloser for a variety of compression formats.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ZReader

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

ZReader is an io.ReadCloser that reads compressed files.

It currently supports bzip2, gzip, and zstd.

func NewReader

func NewReader(r io.Reader) (*ZReader, error)

NewReader returns a ZReader for the given io.ReadCloser. It selects a decompressor based on the first few bytes of data. If it does not have a decompressor to match the bytes, subsequent calls to [Read] will return the raw bytes of the reader. (That might, or might not, be what you want.)

func Open

func Open(pathname string) (*ZReader, error)

Open opens pathname and returns an appropriate ZReader. See NewReader for guidance on its behavior.

func (*ZReader) Close

func (r *ZReader) Close() error

Close closes the ZReader, and will close the underlying reader if it has one.

func (*ZReader) Read

func (r *ZReader) Read(p []byte) (int, error)

Read reads from the appropriate decompressor.

Jump to

Keyboard shortcuts

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