Przeglądaj źródła

Merge pull request #486 from pubnative/fix_snappy

Update snappy repo path and encoding interface
Evan Huus 10 lat temu
rodzic
commit
094e483251
3 zmienionych plików z 5 dodań i 10 usunięć
  1. 1 4
      message.go
  2. 2 2
      snappy.go
  3. 2 4
      snappy_test.go

+ 1 - 4
message.go

@@ -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
 			payload = m.compressedCache
 		default:

+ 2 - 2
snappy.go

@@ -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)
 }
 

+ 2 - 4
snappy_test.go

@@ -19,10 +19,8 @@ var snappyStreamTestCases = map[string][]byte{
 
 func TestSnappyEncode(t *testing.T) {
 	for src, exp := range snappyTestCases {
-		dst, err := snappyEncode([]byte(src))
-		if err != nil {
-			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)
 		}
 	}