Added zlib compression for absolutely zero reason
This commit is contained in:
@@ -22,3 +22,19 @@ func (z *Zlib) Decompress(r io.Reader) ([]byte, error) {
|
||||
}
|
||||
return data.Bytes(), nil
|
||||
}
|
||||
|
||||
//Compress compresses the given data (as a byte array) and returns the compressed data.
|
||||
func (z *Zlib) Compress(data []byte) ([]byte, error) {
|
||||
var buf bytes.Buffer
|
||||
wrt := zlib.NewWriter(&buf)
|
||||
defer wrt.Close()
|
||||
_, err := wrt.Write(data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = wrt.Flush()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user