1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
archivex
========
archivex is a golang package that archives folders (recursively) and files to zip and tar formats.
[](https://travis-ci.org/jhoonb/archivex)
[](http://gocover.io/github.com/jhoonb/archivex)
Installation
-------------
``` bash
$ go get github.com/jhoonb/archivex
```
Example
-------------
```go
package main
import (
"github.com/jhoonb/archivex"
)
// Example using only func zip
func zip() {
zip := new(archivex.ZipFile)
zip.Create("filezip")
zip.Add("testadd.txt", []byte("test 1"))
zip.AddFile("<input_path_file_here>")
zip.AddAll("<input_dir_here", true)
zip.Close()
}
// Example using only func tar
func tar() {
tar := new(archivex.TarFile)
tar.Create("filetar")
tar.Add("testadd.txt", []byte("test 1"))
tar.AddFile("<input_path_file_here>")
tar.AddAll("<input_dir_here", true)
tar.Close()
}
// Example using interface
func usingInterface() {
archx := []archivex.Archivex{&archivex.TarFile{}, &archivex.ZipFile{}}
for _, arch := range archx {
arch.Create("fileinterface")
arch.Add("testadd.txt", []byte("file 1 :) "))
arch.AddFile("<input_path_file_here>")
arch.AddAll("<input_dir_here", true)
arch.Close()
}
}
func main() {
zip()
tar()
usingInterface()
}
```
:)
|