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
Installation
go get github.com/chen-keinan/go-archive-extractor
Supported Archives
Supported Tar Compression
Usage
Zip Usage
zip := extractor.New(extractor.Zip)
headers, err = zip.Extract("common.zip");
fmt.Print(headers)
Tar Usage
tar := extractor.New(extractor.Tar)
headers, err = tar.Extract("common.tar");
if err != nil {
fmt.Print(err.Error())
}
fmt.Print(headers)
Debian Usage
deb := extractor.New(extractor.Deb)
headers, err = deb.Extract("common.deb");
if err != nil {
fmt.Print(err.Error())
}
fmt.Print(headers)
RPM Usage
rpm := extractor.New(extractor.Rpm)
headers, err = rpm.Extract("common.rpm");
if err != nil {
fmt.Print(err.Error())
}
fmt.Print(headers)
7z Usagey
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
}