[GODRIVER-401] Support `json:"-"` tags in the bson encoder Created: 02/May/18 Updated: 27/Oct/23 Resolved: 08/Oct/18 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | BSON |
| Affects Version/s: | 0.0.3 |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Dominic Gregoire | Assignee: | Kristofer Brandow (Inactive) |
| Resolution: | Gone away | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
Protobuf has merged https://github.com/golang/protobuf/tree/dev into master on the 30th of april which will cause problems to anyone using protobuf generated code to encode data to bson. https://groups.google.com/forum/#!topic/protobuf/N-elvFu4dFM Specifically, they added 3 new fields to all generated structs ``` XXX_NoUnkeyedLiteral struct{} `json:"-""` XXX_unrecognized []byte `json:"-""` XXX_sizecache int32 `json:"-"` ``` The fix is to manually add a `bson:"-"` tag, however this breaks any CI that auto-regenerates protobuf on compilation. If the `bson` encoder supported reading the json tags it would work seamlessly.
|
| Comments |
| Comment by Jeff Ithier [ 01/Oct/18 ] |
|
+1 for StructTagParser |
| Comment by Dominic Gregoire [ 27/Sep/18 ] |
|
Yes - StructTagParser is a good idea - this will definitely work out. Best, |
| Comment by Kristofer Brandow (Inactive) [ 27/Sep/18 ] |
|
Hi dgregoire, A new Decoder and Encoder design will be merged into the codebase when Alternatively, you can use the gogo/protobuf library instead of the golang/protobuf one. This library contains support for custom struct tags: https://github.com/gogo/protobuf/blob/master/extensions.md#more-serialization-formats. Do either of those solutions solve your needs? Thanks, Kris |