Skip to content

Commit e7e0dae

Browse files
author
Divjot Arora
authored
GODRIVER-1175 Allow BSON values to decode into non-nilable Go types (#277)
1 parent 4faad42 commit e7e0dae

10 files changed

+471
-130
lines changed

bson/bsoncodec/byte_slice_codec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (bsc *ByteSliceCodec) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader,
5353

5454
var data []byte
5555
var err error
56-
switch vr.Type() {
56+
switch vrType := vr.Type(); vrType {
5757
case bsontype.String:
5858
str, err := vr.ReadString()
5959
if err != nil {
@@ -79,7 +79,7 @@ func (bsc *ByteSliceCodec) DecodeValue(dc DecodeContext, vr bsonrw.ValueReader,
7979
val.Set(reflect.Zero(val.Type()))
8080
return vr.ReadNull()
8181
default:
82-
return fmt.Errorf("cannot decode %v into a []byte", vr.Type())
82+
return fmt.Errorf("cannot decode %v into a []byte", vrType)
8383
}
8484

8585
val.Set(reflect.ValueOf(data))

0 commit comments

Comments
 (0)