File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -222,7 +222,7 @@ func (sc *StructCodec) isZero(i interface{}) bool {
222
222
return true
223
223
}
224
224
225
- if z , ok := v .Interface ().(Zeroer ); ok {
225
+ if z , ok := v .Interface ().(Zeroer ); ok && ( v . Kind () != reflect . Ptr || ! v . IsNil ()) {
226
226
return z .IsZero ()
227
227
}
228
228
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ package bsoncodec
8
8
9
9
import (
10
10
"testing"
11
+ "time"
11
12
12
13
"github.com/stretchr/testify/assert"
13
14
)
@@ -35,4 +36,12 @@ func TestZeoerInterfaceUsedByDecoder(t *testing.T) {
35
36
36
37
z .reportZero = true
37
38
assert .True (t , enc .isZero (z ))
39
+
40
+ // *time.Time with nil should be zero
41
+ var tp * time.Time
42
+ assert .True (t , enc .isZero (tp ))
43
+
44
+ // actually all zeroer if nil should also be zero
45
+ var zp * zeroTest
46
+ assert .True (t , enc .isZero (zp ))
38
47
}
You can’t perform that action at this time.
0 commit comments