Closed chrisroberts closed 2 months ago
Totals | |
---|---|
Change from base Build 9298275274: | 0.0% |
Covered Lines: | 406 |
Relevant Lines: | 419 |
@chrisroberts Nice catch! Could you help me to add an integration test in cursor/encoding_test.go
, by encoding and then decoding to ensure they work expectedly?
You can take other cases as examples:
But I am wondering that []byte
should be also a slice, right? I am not sure why the []byte
case could work perfectly, do you have any idea?
@pilagod Yeah, no problem. Added in the extra tests.
As for the []byte
case, it works because the value on the struct is not the byte slice directly, rather the value is the struct that contains the byte slice. So when the value is reflected, it's not seen as a slice.
Totals | |
---|---|
Change from base Build 9298275274: | 0.0% |
Covered Lines: | 406 |
Relevant Lines: | 419 |
You're right, I totally missed it is under another struct.
Thank you so much for this patch, it looks pretty good to me. I will notify you once there is a new release including this fix 💪
I just released v2.6.1 to include this patch. Thanks again for the contribution. 🙌
Awesome, thank you so much @pilagod!
Encoding a field that is a slice will currently panic due to
Elem()
being called on a slice inutil.ReflectValue
.reflect.Value
only allows forElem()
to be called on interface or pointer values and will panic otherwise. So this just removes slice from being included in the check to unwrap and adds in a test to validate that encoding the slice is successful.