https://github.com/duncanhall/gounzip
A cross-platform utility for unzipping files in Go
https://github.com/duncanhall/gounzip
go golang unzip unzipping-files util zip
Last synced: 5 months ago
JSON representation
A cross-platform utility for unzipping files in Go
- Host: GitHub
- URL: https://github.com/duncanhall/gounzip
- Owner: duncanhall
- License: gpl-3.0
- Created: 2018-04-10T09:44:11.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-22T09:51:57.000Z (almost 8 years ago)
- Last Synced: 2025-03-12T06:33:22.093Z (over 1 year ago)
- Topics: go, golang, unzip, unzipping-files, util, zip
- Language: Go
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gounzip
A cross-platform utility for recursive unzipping in Go, with zero dependencies.
## Install
```
go get github.com/duncanhall/gounzip
```
## Usage
By default, only the source of the zip file is required:
```go
gounzip.Unzip("/home/project/archive.zip")
```
This will unzip to a folder next to the zip file, giving it the same name as the zip (with extension removed). If the default output directory does not exist, it is crated.
Eg, the the example above creates a new driectory at `/home/project/archive` and extracts the contents of the zip into it.
To specifiy a destination directory, provide a `gounzip.Destination` setter:
```go
gounzip.Unzip("/home/project/archive.zip", gounzip.Destination("/home/output/project"))
```
You can skip parts of the zip hierarchy by providing a `gounzip.StripComponents` setter (similar to `tar --strip-components`).
For example supplying `gounzip.StripComponents(1)` will ignore the top-most folder from the output.`
```go
gounzip.Unzip("/home/project/archive.zip", gounzip.StripComponents(1))
```
This can be useful when a top-level folder was zipped, rather than just it's content and you don't want the folder to appear in the output.
Options can be combined, in any order:
```go
gounzip.Unzip("/project/templates.zip", gounzip.StripComponents(1), gounzip.Destination("/project-templates"))
```