@@ -66,10 +66,7 @@ func (m *Message) encode(pe packetEncoder) error {
m.compressedCache = buf.Bytes()
payload = m.compressedCache
case CompressionSnappy:
- tmp, err := snappyEncode(m.Value)
- if err != nil {
- return err
- }
+ tmp := snappyEncode(m.Value)
m.compressedCache = tmp
default:
@@ -4,13 +4,13 @@ import (
"bytes"
"encoding/binary"
- "github.com/golang/snappy/snappy"
+ "github.com/golang/snappy"
)
var snappyMagic = []byte{130, 83, 78, 65, 80, 80, 89, 0}
// SnappyEncode encodes binary data
-func snappyEncode(src []byte) ([]byte, error) {
+func snappyEncode(src []byte) []byte {
return snappy.Encode(nil, src)
}
@@ -19,10 +19,8 @@ var snappyStreamTestCases = map[string][]byte{
func TestSnappyEncode(t *testing.T) {
for src, exp := range snappyTestCases {
- dst, err := snappyEncode([]byte(src))
- t.Error("Encoding error: ", err)
- } else if !bytes.Equal(dst, exp) {
+ dst := snappyEncode([]byte(src))
+ if !bytes.Equal(dst, exp) {
t.Errorf("Expected %s to generate %v, but was %v", src, exp, dst)