[GODRIVER-1117] Allow marshaling custom interfaces inside arrays or structs Created: 10/Jun/19 Updated: 09/Jul/19 Resolved: 09/Jul/19 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Yao Wei | Assignee: | Emmanuel Eppinger (Inactive) |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
This can be considered a follow-up of GODRIVER-842, that the custom interfaces inside arrays or structs cannot be marshaled. Example is shown as follows:
It returns "no encoder found for main.I" in current state. However, bson.Marshal can actaully work with interface{} inside struct, as well as custom interfaces if it is not inside a struct, so I would expect interface{} inside struct should work. |
| Comments |
| Comment by Emmanuel Eppinger (Inactive) [ 09/Jul/19 ] |
|
Hi,
As indicated in
You can do this by doing implementing the codec interface by implementing EncodeValue(EncodeContext, bsonrw.ValueWriter, reflect.Value) error and DecodeValue(DecodeContext, bsonrw.ValueReader, reflect.Value) error.
Thanks, Emmanuel
|