From 51f34a8dba0bbcacac5a178d535c0f626823e525 Mon Sep 17 00:00:00 2001 From: billettc Date: Thu, 12 Nov 2020 17:45:06 -0500 Subject: [PATCH] fix optional test --- encoder.go | 3 +-- encoder_test.go | 7 ++++--- init_test.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/encoder.go b/encoder.go index 3b41a04..88b1909 100644 --- a/encoder.go +++ b/encoder.go @@ -188,13 +188,12 @@ func (e *Encoder) EncodeWithOption(v interface{}, option *EncodeOption) (err err zlog.Debug("field", zap.String("field", field.Name)) } - tag := field.Tag.Get("eos") + tag := field.Tag.Get("bin") if tag == "-" { continue } if v := rv.Field(i); t.Field(i).Name != "_" { - tag = field.Tag.Get("bin") if strings.HasPrefix(tag, "sizeof=") { sizeOfMap[tag] = sizeof(field.Type, v) } diff --git a/encoder_test.go b/encoder_test.go index 1a85f35..3087aa8 100644 --- a/encoder_test.go +++ b/encoder_test.go @@ -3,10 +3,11 @@ package bin import ( "bytes" "encoding/hex" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" "math" "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) func TestEncoder_Float64Inf(t *testing.T) { @@ -69,7 +70,7 @@ func Test_OptionalPrimitiveType(t *testing.T) { func Test_OptionalPointerToPrimitiveType(t *testing.T) { type test struct { - ID *Uint64 `eos:"optional"` + ID *Uint64 `bin:"optional"` } out, err := MarshalBinary(test{ID: nil}) diff --git a/init_test.go b/init_test.go index 5b16a24..1407345 100644 --- a/init_test.go +++ b/init_test.go @@ -5,6 +5,6 @@ import ( ) func init() { - traceEnabled = true + //traceEnabled = true zlog, _ = zap.NewDevelopment() }