mjson2go
is a tool that generates parameterized Go code usable by the MongoDB driver from a JSON
pipeline source.
Want to include this in your development workflow? See the project on Github for full docs and command line options.
Input parameters can be specified as a string in your JSON file prefixed with "%%", and optionally with a Go type specification and ordering for the function arguments:
{ "index": "%%usingIndex%int%2", "date": "%%searchDate%time.Time%1" }
This will produce a function similar to:
func GetAggregation(searchDate time.Time, usingIndex int) bson.D { // ... }