A simple Go command line tool that compresses or decompresses data using flate/deflate compression from a file or stdin.
- Compress data using raw deflate or zlib format
- Decompress flate (zlib) or raw deflate compressed data
- Read from a specified file or from stdin
- Output to stdout
- Support for both zlib format (-z flag) and raw deflate format (default)
Pre-built binaries are available from the releases page. Nightly releases are automatically built and published.
git clone https://github.com/fabricates/flate.git
cd flate
make buildOr without Make:
go build -o flate .go install github.com/fabricates/flate@latest./flate input.txt > compressed.bin./flate -z input.txt > compressed.zlib./flate -d compressed.bin./flate -d -z compressed.zlibIf the input is base64-encoded, use -b to decode before processing. This is useful when you receive compressed data embedded in text formats.
# Decompress base64-encoded zlib data from stdin
cat compressed.zlib.b64 | ./flate -b -d -zcat input.txt | ./flate > compressed.bin./flate -h# Compress text with raw deflate
echo "hello world!" | ./flate > compressed.bin
# Decompress it back
./flate -d compressed.bin# Compress with zlib
echo "hello world!" | ./flate -z > compressed.zlib
# Decompress zlib
./flate -d -z compressed.zlibcurl -s https://example.com/data.txt | ./flate -z | ./flate -d -z# Compress a file
./flate largefile.txt > largefile.deflate
# Decompress it
./flate -d largefile.deflate > restored.txt-
Input: The tool reads data from either:
- A file specified as a command line argument
- Standard input (stdin) if no file is specified
-
Process: The data is processed using:
- Compression (default): Compress input using raw deflate or zlib format (-z flag)
- Decompression (-d flag): Decompress using raw deflate or zlib format (-z flag)
-
Output: The processed content is written to standard output (stdout)
The tool will exit with an error message if:
- The specified file cannot be opened
- The input data cannot be processed (compressed/decompressed) as flate/deflate
- The compression format doesn't match the selected mode (zlib vs raw deflate) during decompression
- Any I/O operation fails
Use the provided Makefile for common development tasks:
make build # Build the binary
make test # Run tests
make build-all # Build for all platforms
make demo # Run demo with test data
make clean # Clean build artifacts
make help # Show all available targetsRun the test suite:
make testOr use Go directly:
go test -v ./...This project uses GitHub Actions for:
- Continuous Integration: Tests are run on every push and pull request
- Nightly Releases: Automated builds and releases every night at 2:00 AM UTC
- Multi-platform Builds: Binaries are built for Linux, macOS, and Windows (x86_64 and ARM64)
- Go 1.21 or later
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License
Copyright (c) 2025
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.