Skip to content

open source lib for extracting most common archives with diffrents compressions

License

Notifications You must be signed in to change notification settings

chen-keinan/go-archive-extractor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Report Card License test coverage badge Gitter


arc-extract logo

go-archive-extractor

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

  • tar
  • zip
  • rpm
  • deb
  • 7zip

Supported Tar Compression

  • bz2
  • gz
  • Z
  • infla
  • xp3
  • xz

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)
}

Archive Header

type ArchiveHeader struct {
Name          string
ModTime       int64
Size          int64
Sha1          string
Sha2          string
PkgMeta       map[string]interface{}
ArchiveReader io.Reader
}

About

open source lib for extracting most common archives with diffrents compressions

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published