The archive-extractor is an open-source library for extracting various archive types.
it returns archive headers metadata (name,size,timestamp,sha1 and sha256)
it also supports different types of tar compressions
go get github.com/chen-keinan/go-archive-extractor
- tar
- zip
- rpm
- deb
- 7zip
- bz2
- gz
- Z
- infla
- xp3
- xz
zip := extractor.New(extractor.Zip)
headers, err = zip.Extract("common.zip");
fmt.Print(headers)
tar := extractor.New(extractor.Tar)
headers, err = tar.Extract("common.tar");
if err != nil {
fmt.Print(err.Error())
}
fmt.Print(headers)
deb := extractor.New(extractor.Deb)
headers, err = deb.Extract("common.deb");
if err != nil {
fmt.Print(err.Error())
}
fmt.Print(headers)
rpm := extractor.New(extractor.Rpm)
headers, err = rpm.Extract("common.rpm");
if err != nil {
fmt.Print(err.Error())
}
fmt.Print(headers)
sevenZip := extractor.New(extractor.SevenZip)
headers, err = sevenZip.Extract("common.7z");
if err != nil {
fmt.Print(err.Error())
}
fmt.Print(headers)
package main
import (
"fmt"
"github.com/chen-keinan/go-archive-extractor/pkg/extractor"
)
func main() {
zip := extractor.New(extractor.Zip)
headers, err := zip.Extract("common.zip")
if err != nil {
fmt.Print(err.Error())
}
fmt.Print(headers)
}
type ArchiveHeader struct {
Name string
ModTime int64
Size int64
Sha1 string
Sha2 string
PkgMeta map[string]interface{}
ArchiveReader io.Reader
}