In order for this to be possible, you would need these things:
- Access to a
Reader
for the incoming bson stream - A datatype for generic document parts
- A streaming decoder for bson which reads from the
Reader
and produces document parts - A streaming encoder for json that consumes document parts and writes to a
Writer
mgo
does not provide number 1. encoding/json
does not provide number 2 or 4. mgo/bson
does not provide number 3. A bit of googling doesn't turn up any help for any of those points in Go, though there are streaming json parsers in other languages (see answers for Is there a streaming API for JSON?).
Your desire to do this is reasonable, but the support just doesn't exist yet. Fortunately, json and bson are simple enough and all the components you're using are open source, so in theory you could write the tools you need.