https://github.com/enr/zipext
Go library to manipulate zip files
https://github.com/enr/zipext
go go-library hacktoberfest zip
Last synced: 5 months ago
JSON representation
Go library to manipulate zip files
- Host: GitHub
- URL: https://github.com/enr/zipext
- Owner: enr
- License: apache-2.0
- Created: 2014-03-01T12:33:02.000Z (over 12 years ago)
- Default Branch: main
- Last Pushed: 2022-09-24T17:09:29.000Z (over 3 years ago)
- Last Synced: 2025-08-14T22:35:50.267Z (10 months ago)
- Topics: go, go-library, hacktoberfest, zip
- Language: Go
- Homepage:
- Size: 33.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go zipext


[](https://pkg.go.dev/github.com/enr/zipext)
[](https://goreportcard.com/report/github.com/enr/zipext)
Go library to manipulate zip files.
Import library:
```Go
import (
"github.com/enr/zipext"
)
```
Create a zip archive:
```Go
contents := "/path/to/files"
zipPath := "/path/to/archive.zip"
err := zipext.Create(contents, zipPath)
if err != nil {
t.Errorf("error in Create(%s,%s): %s %s", contents, zipPath, reflect.TypeOf(err), err.Error())
}
```
Extract contents from zip:
```Go
err = zipext.Extract(zipPath, extractPath)
if err != nil {
t.Errorf("error in Extract(%s,%s): %s %s", zipPath, unzipDir, reflect.TypeOf(err), err.Error())
}
```
Visit zip contents:
```Go
err := zipext.Walk(path, func(f *zip.File, err error) error {
if err != nil {
return err
}
fmt.Printf("- %#v\n", f)
return nil
})
```
Check if file is valid zip:
```Go
p := "/path/to/archive.zip"
valid, err := zipext.IsValidZip(p)
if err != nil {
t.Errorf("got error checking for valid zip '%s'", p)
}
```
## License
Apache 2.0 - see LICENSE file.
Copyright 2014-TODAY zipext contributors