Replies: 1 comment
|
Your technical analysis is spot on — the dependency concern is real and your suggestion aligns with Gin's existing extensibility pattern. Your concerns validated You're correct on all points:
The existing pattern supports your suggestion Gin already has exactly this separation for other optional bindings via the gin-contrib org:
BSON binding/rendering fits naturally as The specific change that introduced this PR #4705 added BSON support in the 1.12.0 release. Looking at that PR, the BSON binding and render are self-contained files (binding/bson.go and render/bson.go) with no deep coupling to Gin internals — further confirming that extraction to gin-contrib/bson would Precedent from other frameworks Echo (another popular Go HTTP framework) keeps its core dependency tree minimal and pushes protocol-specific bindings into middleware packages. The Go standard library itself follows this philosophy: |
Uh oh!
There was an error while loading. Please reload this page.
I noticed that Gin 1.12 introduced BSON binding/render support by depending on the MongoDB Go Driver (
go.mongodb.org/mongo-driver/v2).While BSON support itself is a useful feature, I'm wondering whether it should live in the core package.
Concern
Most Gin applications:
However, all users now indirectly depend on the MongoDB driver.
Although Go's linker removes unused code from the final binary, introducing a new core dependency still has some costs:
Suggestion
Would it make sense to move BSON support into an optional package (for example,
gin-contrib/bson)?Something like:
Users who need BSON can explicitly opt in, while keeping the core dependency tree smaller.
Is there a particular reason why BSON support was chosen to be included directly in Gin instead of as an optional extension?
I'd be interested in hearing the design considerations.
All reactions