gcompress

package
v0.0.0-...-37ff87a Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2024 License: MIT Imports: 18 Imported by: 2

README

UnpackIt

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

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

Usage

Unpack a file:

    file, _ := os.Open(test.filepath)
    destPath, err := gcompress.Unpack(file, tempDir)

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

    res, err := http.Get(url)
    destPath, err := gcompress.Unpack(res.Body, tempDir)

Documentation

Overview

Package gcompress allows you to easily unpack *.tar.gz, *.tar.bzip2, *.tar.xz, *.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 Unpack

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

Unpack unpacks a compressed stream. Magic numbers are used to determine what decompressor and/or unarchiver to use.

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(r io.Reader, destPath string) (string, error)

Unzip unpacks a ZIP stream. When given a os.File reader it will get its size without reading the entire zip file in memory.

Types

This section is empty.

Jump to

Keyboard shortcuts

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