[GODRIVER-642] unmarshal private fields Created: 19/Nov/18 Updated: 27/Oct/23 Resolved: 04/Jan/19 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | BSON |
| Affects Version/s: | 0.0.18 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Ivan Egorov | Assignee: | Kristofer Brandow (Inactive) |
| Resolution: | Gone away | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
go - 1.11.2 |
||
| Attachments: |
|
| Description |
|
OK: ok.go
FAIL: fail.go
|
| Comments |
| Comment by Kristofer Brandow (Inactive) [ 04/Jan/19 ] |
|
Closing due to inactivity. |
| Comment by Kristofer Brandow (Inactive) [ 19/Nov/18 ] |
|
Hi vany.egorov, The reflection library in Go does not allow the setting of private struct fields. If you need the field to be private and want to marshal it, have the type implement the bsoncodec.Proxy interface. This will allow you to return a struct with the private field as public which can then be handled. For unmarhsaling you can implement the bsoncodec.ValueUnmarshaler interface. Let me know if you have any other questions. --Kris |