unzipit

package module
v0.0.0-...-04173d2 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2016 License: MPL-2.0 Imports: 16 Imported by: 1

README

UnzipIt

![Gitter](https://badges.gitter.im/Join Chat.svg) GoDoc Build Status

This Go library allows you to easily unpack the following files:

  • tar.gz
  • tar.bzip2
  • zip
  • tar

There are not CGO involved nor hard dependencies of any type.

Usage

Unpack a file:

    file, err := os.Open(test.filepath)
    ok(t, err)
    defer file.Close()

    destPath, err := unzipit.Unpack(file, tempDir)

Unpack a stream (such as a http.Response):

    res, err := http.Get(url)
    destPath, err := unzipit.UnpackStream(res.Body, tempDir)

Documentation

Overview

Package unzipit allows you to easily unpack *.tar.gz, *.tar.bzip2, *.zip and *.tar files. There are not CGO involved nor hard dependencies of any type.

Package unzipit allows you to easily unpack *.tar.gz, *.tar.bzip2, *.zip and *.tar files. There are not CGO involved nor hard dependencies of any type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bunzip2

func Bunzip2(file *os.File) (*bufio.Reader, error)

Bunzip2 decompresses a bzip2 file and returns the decompressed stream

func Bunzip2Stream

func Bunzip2Stream(reader io.Reader) (*bufio.Reader, error)

Bunzip2Stream unpacks a bzip2 stream

func Gunzip

func Gunzip(file *os.File) (*bufio.Reader, error)

Gunzip decompresses a gzip file and returns the decompressed stream

func GunzipStream

func GunzipStream(reader io.Reader) (*bufio.Reader, error)

GunzipStream unpacks a gzipped stream

func Unpack

func Unpack(file *os.File, destPath string) (string, error)

Unpack unpacks a compressed and archived file and places result output in destination path.

File formats supported are:

  • .tar.gz
  • .tar.bzip2
  • .zip
  • .tar

If it cannot recognize the file format, it will save the file, as is, to the destination path.

func UnpackStream

func UnpackStream(reader io.Reader, destPath string) (string, error)

UnpackStream unpacks a compressed stream. Note that if the stream is a using ZIP compression (but only ZIP compression), it's going to get buffered in its entirety to memory prior to decompression.

func Untar

func Untar(data io.Reader, destPath string) (string, error)

Untar unarchives a TAR archive and returns the final destination path or an error

func Unzip

func Unzip(file *os.File, destPath string) (string, error)

Unzip decompresses and unarchives a ZIP archive, returning the final path or an error

func UnzipStream

func UnzipStream(r io.Reader, destPath string) (string, error)

UnzipStream unpacks a ZIP stream. Because of the nature of the ZIP format, the stream is copied to memory before decompression.

Types

This section is empty.

Jump to

Keyboard shortcuts

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