package gzip

import "github.com/google/go-containerregistry/internal/gzip"

Package gzip provides helper functions for interacting with gzipped streams.

Index

Functions

func Is

func Is(r io.Reader) (bool, error)

Is detects whether the input stream is compressed.

func ReadCloser

func ReadCloser(r io.ReadCloser) io.ReadCloser

ReadCloser reads uncompressed input data from the io.ReadCloser and returns an io.ReadCloser from which compressed data may be read. This uses gzip.BestSpeed for the compression level.

func ReadCloserLevel

func ReadCloserLevel(r io.ReadCloser, level int) io.ReadCloser

ReadCloserLevel reads uncompressed input data from the io.ReadCloser and returns an io.ReadCloser from which compressed data may be read. Refer to compress/gzip for the level: https://golang.org/pkg/compress/gzip/#pkg-constants

func UnzipReadCloser

func UnzipReadCloser(r io.ReadCloser) (io.ReadCloser, error)

UnzipReadCloser reads compressed input data from the io.ReadCloser and returns an io.ReadCloser from which uncompessed data may be read.

Types

type PeekReader

type PeekReader interface {
	io.Reader
	Peek(n int) ([]byte, error)
}

PeekReader is an io.Reader that also implements Peek a la bufio.Reader.

func Peek

func Peek(r io.Reader) (bool, PeekReader, error)

Peek detects whether the input stream is gzip compressed.

If r implements Peek, we will use that directly, otherwise a small number of bytes are buffered to Peek at the gzip header, and the returned PeekReader can be used as a replacement for the consumed input io.Reader.

Source Files

zip.go

Version
v0.11.0
Published
Jul 20, 2022
Platform
js/wasm
Imports
5 packages
Last checked
4 hours ago

Tools for package owners.