-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
-
None
-
Go Drivers
Context
bson.Zeroer only works when implemented on a struct type. It’d be nice if it could work on any type.
Describe the background behind the problem.
Before I realized that GODRIVER-3223 was a bug (thank you, preston.vasquez@mongodb.com!), I tried implementing Zeroer on our wrapper around Google’s UUID package. Then I saw that the Zeroer docs say it’s only for structs, which is rather a surprise.
Definition of done
The encoder should honor IsZero() on any type, not just structs.
Pitfalls
What should the implementer watch out for? What are the risks?
This could count as a breaking change since IsZero() could conceptually be implemented on some type independently of BSON. IOW, there could be “accidental” Zeroer implementations out there.
- is related to
-
GODRIVER-2765 Add an "omitzero" BSON struct tag
- Backlog
-
GODRIVER-3223 `omitempty` never applies to arrays
- Closed