Help us shape the future of Go! Take the 2026 Go Developer Survey

gzip

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package gzip implements the `gzip`, `gunzip`, and `zcat` built-ins. All three share a single implementation parameterized by the default mode (compress, decompress, decompress-to-stdout).

Flags:

-d           decompress (gzip only; gunzip implies it)
-k           keep input file (do not unlink)
-c           write output to stdout instead of <name>.gz / <name>
-N           use original filename stored in the gzip header
-r           recurse into directories
-l           list contents (compressed size, uncompressed size, ratio, name)
-1..-9       compression level (compress only)
--help       show this help and exit 0

All file I/O routes through Context.FS; stdin via Context.Stdin; stdout via Context.Stdout.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() command.Command

New returns the gzip command.

func Run

func Run(c *command.Context, args []string, mode Mode) command.Result

Run is the shared entrypoint for gzip / gunzip / zcat.

Types

type Mode

type Mode int

Mode selects the default behavior for a gzip-family invocation.

const (
	// ModeCompress — `gzip`. Default: compress each named file in
	// place, writing <name>.gz. With -d it decompresses.
	ModeCompress Mode = iota
	// ModeDecompress — `gunzip`. Default: decompress each named .gz
	// file, writing the trimmed name.
	ModeDecompress
	// ModeZcat — `zcat`. Equivalent to `gunzip -c`: decompress to
	// stdout, never touch the original.
	ModeZcat
)

Jump to

Keyboard shortcuts

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