I wrote the following test which reflects a problem that we ran into during our migration from mgobson. It was easy to amend our code to avoid this situation, but the error message that you get from Unmarshal in this situation is "cannot decode binary into a slice", which isn't super intuitive, particularly without context, and because the "First" field is what a developer would think of as a slice.
func TestBinarySlice(t *testing.T) { type raw []byte type fob struct { First raw `bson:"first"` } inter := M{ "first": []byte("foo"), } data, err := Marshal(inter) require.NoError(t, err) out := fob{} err = Unmarshal(data, &out) require.NoError(t, err) require.Equal(t, string(out.First), "foo") }