tgz

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

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

Go to latest
Published: Dec 20, 2016 License: MIT Imports: 6 Imported by: 18

README

tgz GoDoc Build Status codecov

A Go library to extract tgz files to temporal directories.

Example

The following program will decompress the file "/tmp/foo.tgz" to a temporal directory, print the names of all the files and directories in it and delete the temporal directory:

package main

import (
	"fmt"
	"io/ioutil"
	"os"

	"github.com/alcortesm/tgz"
)

func main() {
	tmpPath, err := tgz.Extract("/tmp/foo.tgz")
	if tmpPath != "" {
		defer os.RemoveAll(tmpPath)
	}
	if err != nil {
		panic(err)
	}

	infos, err := ioutil.ReadDir(tmpPath)
	if err != nil {
		panic(err)
	}

	for _, info := range infos {
		fmt.Println(info.Name())
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Extract

func Extract(tgz string) (d string, err error)

Extract decompress a gziped tarball into a new temporal directory created just for this purpose.

On success, the path of the newly created directory and a nil error is returned.

A non-nil error is returned if the method fails to complete. The returned path will be an empty string if no information was extracted before the error and the temporal directory has not been created. Otherwise, a non-empty string with the temporal directory holding whatever information was extracted before the error is returned.

Types

This section is empty.

Jump to

Keyboard shortcuts

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