diff --git a/encoder.go b/encoder.go index 54f9c41..b9fb199 100644 --- a/encoder.go +++ b/encoder.go @@ -264,13 +264,8 @@ func (e *Encoder) WriteUint128(i Uint128, order binary.ByteOrder) (err error) { zlog.Debug("encode: write uint128", zap.Stringer("hex", i), zap.Uint64("lo", i.Lo), zap.Uint64("hi", i.Hi)) } buf := make([]byte, TypeSize.Uint128) - if order == binary.BigEndian { - order.PutUint64(buf, i.Hi) - order.PutUint64(buf[TypeSize.Uint64:], i.Lo) - } else { - order.PutUint64(buf, i.Lo) - order.PutUint64(buf[TypeSize.Uint64:], i.Hi) - } + order.PutUint64(buf, i.Lo) + order.PutUint64(buf[TypeSize.Uint64:], i.Hi) return e.toWriter(buf) } @@ -279,13 +274,8 @@ func (e *Encoder) WriteInt128(i Int128, order binary.ByteOrder) (err error) { zlog.Debug("encode: write int128", zap.Stringer("hex", i), zap.Uint64("lo", i.Lo), zap.Uint64("hi", i.Hi)) } buf := make([]byte, TypeSize.Uint128) - if order == binary.BigEndian { - order.PutUint64(buf, i.Hi) - order.PutUint64(buf[TypeSize.Uint64:], i.Lo) - } else { - order.PutUint64(buf, i.Lo) - order.PutUint64(buf[TypeSize.Uint64:], i.Hi) - } + order.PutUint64(buf, i.Lo) + order.PutUint64(buf[TypeSize.Uint64:], i.Hi) return e.toWriter(buf) } diff --git a/encoder_test.go b/encoder_test.go index 4afb5f9..e41df51 100644 --- a/encoder_test.go +++ b/encoder_test.go @@ -73,7 +73,6 @@ func TestEncoder_safeString(t *testing.T) { assert.Equal(t, []byte{ 0x5, 0x68, 0x65, 0x6c, 0x6c, 0x6f, }, buf.Bytes()) - } func TestEncoder_int8(t *testing.T) { @@ -152,7 +151,7 @@ func TestEncoder_int64(t *testing.T) { assert.Equal(t, []byte{ 0x91, 0x7d, 0xf3, 0xff, 0xff, 0xff, 0xff, 0xff, //-819823 - 0xe3, 0x1c, 0x1, 0x00, 0x00, 0x00, 0x00, 0x00, //72931 + 0xe3, 0x1c, 0x1, 0x00, 0x00, 0x00, 0x00, 0x00, // 72931 }, buf.Bytes()) // big endian @@ -164,7 +163,7 @@ func TestEncoder_int64(t *testing.T) { assert.Equal(t, []byte{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xf3, 0x7d, 0x91, //-819823 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x1, 0x1c, 0xe3, //72931 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x1, 0x1c, 0xe3, // 72931 }, buf.Bytes()) } @@ -242,8 +241,8 @@ func TestEncoder_uint64(t *testing.T) { enc.WriteUint64(uint64(72931), LE) assert.Equal(t, []byte{ - 0x6f, 0x82, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, //819823 - 0xe3, 0x1c, 0x1, 0x00, 0x00, 0x00, 0x00, 0x00, //72931 + 0x6f, 0x82, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, // 819823 + 0xe3, 0x1c, 0x1, 0x00, 0x00, 0x00, 0x00, 0x00, // 72931 }, buf.Bytes()) // big endian @@ -254,8 +253,8 @@ func TestEncoder_uint64(t *testing.T) { enc.WriteUint64(uint64(72931), BE) assert.Equal(t, []byte{ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x82, 0x6f, //819823 - 0x00, 0x00, 0x00, 0x00, 0x00, 0x1, 0x1c, 0xe3, //72931 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x82, 0x6f, // 819823 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x1, 0x1c, 0xe3, // 72931 }, buf.Bytes()) } @@ -494,7 +493,6 @@ func TestEncoder_BinaryStruct(t *testing.T) { } func TestEncoder_BinaryTestStructWithTags(t *testing.T) { - s := &binaryTestStructWithTags{ F1: "abc", F2: -75, @@ -1115,7 +1113,6 @@ func Test_writeArrayOfUint32(t *testing.T) { ), buf.Bytes()) } - } func Test_writeArrayOfUint64(t *testing.T) {