extract
A Go library to extract archives in zip, tar.gz or tar.bz2 formats
extract: archives without the format branch
A small Go library for zip, tar.gz, and tar.bz2 extraction where a renamer callback controls every path and an Archive function sniffs the format from the first bytes.
The basic call
Most of the time extraction is one call: pass a Reader and a destination and the archive comes out the other side. The library covers zip, tar.gz, and tar.bz2, so the common cases do not require thinking about which format is in hand. It is MIT licensed and aimed at Go programs that need to unpack archives without pulling in a heavy dependency, and the call signature stays the same across all three formats.
A renamer for control
When you want more say over the output, such as pulling only a subfolder out of the archive, you supply a renamer function that changes the path for every file. That callback is the whole mechanism for steering where each extracted entry lands, so the library stays generic while the caller decides the layout. It is the sort of hook that looks small in the README and turns out to cover most real-world extraction needs.
Detection and the minimal interface
If the archive type is unknown, the Archive function infers it from the first bytes, so callers can skip specifying the format, which the README treats as the pleasant surprise case. The library also exposes a minimal interface holding only the function needed for an extraction. That makes it easy to wrap the os functions to chroot a path, scramble files, fire an event per operation, or reimplement them against an in-memory store, which is a small seam that opens up a lot of uses. Because the interface is so thin, swapping in a custom implementation for testing or sandboxing is almost trivial.
Community notes