lz4c¶
A pure-Go CLI for go-compressions/lz4 — the LZ4 block format on
the command line, as a single CGO-free static binary.
Repository →
Usage¶
- Compresses by default;
-d/--decompressdecompresses. -i/--inputdefaults to stdin.-o/--outputdefaults to stdout.-v/--verboseprints a summary line to stderr with byte counts, compression ratio (compress only), and elapsed time:
Without -v, lz4c stays silent so the binary output on stdout is safe to
pipe.
Examples¶
# Compress a file to disk.
lz4c -i big.bin -o big.bin.lz4
# Round-trip through a pipe.
cat big.bin | lz4c | lz4c -d > restored.bin
# Show timing + ratio.
lz4c -v -i big.bin -o big.bin.lz4
Container format¶
The lz4 library exposes the LZ4 block codec only, which does not record the
decompressed length. lz4c frames each block with a fixed 12-byte header so a
stream is self-describing:
magic [4]byte // "LZ4C"
rawLen uint64 // little-endian length of the original data
...block... // a standard LZ4 block, byte-for-byte
The payload after the header is an unmodified, standard LZ4 block and stays
wire-compatible with pierrec/lz4: strip the
12-byte header and any LZ4 block decoder consumes the remainder.
Build¶
Coverage¶
task test reports 100% statement coverage across all three packages:
| Package | Role |
|---|---|
cmd/lz4c |
main and the cobra root command |
cmd/lz4c/lz4io |
container framing over the LZ4 blocks |
cmd/lz4c/internal/cmdio |
shared stdin/stdout/file IO helpers |
The package ships a Taskfile (task lint|build|test|ci)
used by both local development and CI; Renovate auto-merges patch/minor gomod
updates.
License¶
BSD-3-Clause.