This is a pure Go implementation of antirez's SMAZ, a library for compressing short, English strings (it won't work well for other languages).
$ go get github.com/epk/smaz
import (
"github.com/epk/smaz"
)
func main() {
s := "Now is the time for all good men to come to the aid of the party."
compressed := smaz.Encode(nil, []byte(s))
decompressed, err := smaz.Decode(nil, compressed)
if err != nil {
fmt.Printf("decompressed: %s\n", string(decompressed))
...
}
Full API documentation.
This is not a direct port of the C version. It is not guaranteed that the output
of smaz.Encode
will be precisely the same as the C library. However, the
output should be decompressible by the C library, and the output of the C
library should be decompressible by smaz.Decode
.
Salvatore Sanfilippo designed SMAZ and wrote [C implementation]](https://github.com/antirez/smaz).
Caleb Spare wrote initial Go port.
Krzysztof Kowalczyk improved speed of decompression (2.4x faster) and compression (1.3x faster).
MIT Licensed.