BSON codecs for Google's protocol buffers.
This library provides add-ons to go.mongodb.org/mongo-driver for first-class protobuf support with similar API design, extensive testing and high reuse of already existing codecs. The following types are currently mapped:
This list will grow as we add support for most Well-Known Types as well as Google APIs Common Types.
$ go get go.vallahaye.net/protobson
// Set client options
clientOptions := options.Client().
SetRegistry(protobson.DefaultRegistry).
ApplyURI("mongodb://localhost:27017")
// Connect to MongoDB
client, err := mongo.Connect(context.TODO(), clientOptions)
if err != nil {
log.Fatal(err)
}
// Check the connection
err = client.Ping(context.TODO(), nil)
if err != nil {
log.Fatal(err)
}
fmt.Println("Connected to MongoDB!")