detectreader

package module
v0.0.0-...-9bcd584 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2018 License: MIT Imports: 6 Imported by: 0

README

Mascot
Detect Reader

GoDoc License Go Report Card

Detect reader reads the first bytes looking for magic bytes. Then it returns an appropriate reader for that stream.

Installation

Windows, OS X & Linux:

go get github.com/gurre/detectreader

Usage examples

Simple usage:

// Some compressed byte stream
reader := bytes.NewReader(b)
// The returned reader is a decompressor
decompressedReader, err := Decompress(reader)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decompress

func Decompress(stream io.Reader) (io.Reader, error)

Decompress takes a reader, detects magic bytes and returns another reader for that compression

Types

type Compression

type Compression int

Compression represents the supported compress readers

const (
	// Uncompressed is the same reader you passed in
	Uncompressed Compression = iota
	// Bzip2 is a reader
	Bzip2
	// Gzip is a reader
	Gzip
	// Xz is a reader
	Xz
)

func DetectCompression

func DetectCompression(source []byte) Compression

DetectCompression compares for any magic bytes

func (*Compression) Extension

func (compression *Compression) Extension() string

Extension returns the file extension for the detected type

Jump to

Keyboard shortcuts

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