github.com/qxnw/lib4go@v0.0.0-20180426074627-c80c7e84b925/archiver/README.md (about) 1 archiver [![archiver GoDoc](https://img.shields.io/badge/reference-godoc-blue.svg?style=flat-square)](https://godoc.org/github.com/mholt/archiver) [![Linux Build Status](https://img.shields.io/travis/mholt/archiver.svg?style=flat-square&label=linux+build)](https://travis-ci.org/mholt/archiver) [![Windows Build Status](https://img.shields.io/appveyor/ci/mholt/archiver.svg?style=flat-square&label=windows+build)](https://ci.appveyor.com/project/mholt/archiver) 2 ======== 3 4 Package archiver makes it trivially easy to make and extract common archive formats such as .zip, and .tar.gz. Simply name the input and output file(s). 5 6 Files are put into the root of the archive; directories are recursively added, preserving structure. 7 8 The `archiver` command runs the same cross-platform and has no external dependencies (not even libc); powered by the Go standard library, [dsnet/compress](https://github.com/dsnet/compress), [nwaples/rardecode](https://github.com/nwaples/rardecode), and [ulikunitz/xz](https://github.com/ulikunitz/xz). Enjoy! 9 10 Supported formats/extensions: 11 12 - .zip 13 - .tar 14 - .tar.gz & .tgz 15 - .tar.bz2 & .tbz2 16 - .tar.xz & .txz 17 - .tar.lz4 & .tlz4 18 - .tar.sz & .tsz 19 - .rar (open only) 20 21 22 ## Install 23 24 ```bash 25 go get github.com/mholt/archiver/cmd/archiver 26 ``` 27 28 Or download binaries from the [releases](https://github.com/mholt/archiver/releases) page. 29 30 31 ## Command Use 32 33 Make a new archive: 34 35 ```bash 36 $ archiver make [archive name] [input files...] 37 ``` 38 39 (At least one input file is required.) 40 41 To extract an archive: 42 43 ```bash 44 $ archiver open [archive name] [destination] 45 ``` 46 47 (The destination path is optional; default is current directory.) 48 49 The archive name must end with a supported file extension—this is how it knows what kind of archive to make. Run `archiver -h` for more help. 50 51 52 ## Library Use 53 54 ```go 55 import "github.com/mholt/archiver" 56 ``` 57 58 Create a .zip file: 59 60 ```go 61 err := archiver.Zip.Make("output.zip", []string{"file.txt", "folder"}) 62 ``` 63 64 Extract a .zip file: 65 66 ```go 67 err := archiver.Zip.Open("input.zip", "output_folder") 68 ``` 69 70 Working with other file formats is exactly the same, but with [their own Archiver implementations](https://godoc.org/github.com/mholt/archiver#Archiver). 71 72 73 74 ## FAQ 75 76 #### Can I list a file in one folder to go into a different folder in the archive? 77 78 No. This works just like your OS would make an archive in the file explorer: organize your input files to mirror the structure you want in the archive. 79 80 81 #### Can it add files to an existing archive? 82 83 Nope. This is a simple tool; it just makes new archives or extracts existing ones.