gozip

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2026 License: MIT

README

gozip

A Go implementation of zip and unzip, compatible with standard tools.

Why?

Some Docker and cloud environments come with the Go toolchain but lack zip/unzip, and installing system packages may require root access or pulling in extra dependencies. With gozip, a single go install gives you both tools — no package manager, no apt-get, no source compilation needed. It is designed as a lightweight, quick-to-install replacement for environments where the standard utilities are not readily available.

Installation

go install github.com/jaeyeom/gozip/cmd/gozip@latest
go install github.com/jaeyeom/gozip/cmd/gounzip@latest

Usage

gozip — create zip archives
# Zip individual files
gozip archive.zip file1.txt file2.txt

# Zip a directory recursively
gozip -r archive.zip mydir/

# Set compression level (0=store, 1=fastest, 9=best)
gozip -r -9 archive.zip mydir/

# Exclude files by pattern
gozip -r -x '*.log' archive.zip mydir/
gounzip — extract zip archives
# Extract an archive
gounzip archive.zip

# Extract to a specific directory
gounzip -d output/ archive.zip

# Overwrite existing files
gounzip -o archive.zip

# List archive contents
gounzip -l archive.zip

# Extract only matching files
gounzip archive.zip '*.txt'

# Strip directory paths on extraction
gounzip -j archive.zip

Library

The ziplib package provides the core functionality for use in other Go programs:

import "github.com/jaeyeom/gozip/ziplib"

// Create a zip archive.
err := ziplib.Zip("archive.zip", []string{"file1.txt", "dir/"}, ziplib.ZipOptions{
    Recursive:        true,
    CompressionLevel: 6,
    ExcludePatterns:  []string{"*.log"},
    Output:           os.Stdout,
})

// Extract a zip archive.
err := ziplib.Unzip("archive.zip", ziplib.UnzipOptions{
    OutputDir: "output/",
    Overwrite: true,
    Output:    os.Stdout,
})

// List archive entries.
entries, err := ziplib.List("archive.zip")

Development

# Format, lint, test, and build
make all

# CI-friendly checks (no mutation)
make check

# Run tests only
make test

# Build binaries to bin/
make build

License

MIT

Directories

Path Synopsis
cmd
gounzip command
Command gounzip extracts zip archives.
Command gounzip extracts zip archives.
gozip command
Command gozip creates zip archives.
Command gozip creates zip archives.
Package ziplib provides core zip/unzip functionality.
Package ziplib provides core zip/unzip functionality.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL