Documentation ¶
Overview ¶
Package extract allows to extract archives in zip, tar.gz or tar.bz2 formats easily.
Most of the time you'll just need to call the proper function with a buffer and a destination:
data, _ := ioutil.ReadFile("path/to/file.tar.bz2") buffer := bytes.NewBuffer(data) extract.TarBz2(data, "/path/where/to/extract", nil)
Sometimes you'll want a bit more control over the files, such as extracting a subfolder of the archive. In this cases you can specify a renamer func that will change the path for every file:
var shift = func(path string) string { parts := strings.Split(path, string(filepath.Separator)) parts = parts[1:] return strings.Join(parts, string(filepath.Separator)) } extract.TarBz2(data, "/path/where/to/extract", shift)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Tar ¶
Tar extracts a .tar archived stream of data in the specified location. It accepts a rename function to handle the names of the files (see the example)
func TarBz2 ¶
TarBz2 extracts a .tar.bz2 archived stream of data in the specified location. It accepts a rename function to handle the names of the files (see the example)