Pure Go implementation of bzip2 compression and decompression, based on the bzip2 1.0.8 reference C implementation.
Unlike the standard library's compress/bzip2 which only supports decompression, this package provides both compression and decompression.
go get github.com/KarpelesLab/gobzip2var buf bytes.Buffer
w := gobzip2.NewWriter(&buf)
w.Write([]byte("hello, world"))
w.Close()r := gobzip2.NewReader(bytes.NewReader(compressed))
data, err := io.ReadAll(r)go install github.com/KarpelesLab/gobzip2/cmd/gobzip2@latest
# Compress
gobzip2 file.txt
# Decompress
gobzip2 -d file.txt.bz2
# Pipe
cat file | gobzip2 | gobzip2 -d