Skip to content

Commit

Permalink
fix optional test
Browse files Browse the repository at this point in the history
  • Loading branch information
billettc committed Nov 12, 2020
1 parent 11b351a commit 51f34a8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
7 changes: 4 additions & 3 deletions encoder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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})
Expand Down
2 changes: 1 addition & 1 deletion init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import (
)

func init() {
traceEnabled = true
//traceEnabled = true
zlog, _ = zap.NewDevelopment()
}

0 comments on commit 51f34a8

Please sign in to comment.