Hi @Yishai_Berg ! Thank you for bringing this to our attention. I’ve created GODRIVER-3071 to correct the documentation. The Go Driver will only use this “minimum int” logic when defined:
package main
import (
"bytes"
"fmt"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsonrw"
)
func main() {
type foo struct {
Bar uint32
}
buf := new(bytes.Buffer)
vw, err := bsonrw.NewBSONValueWriter(buf)
if err != nil {
panic(err)
}
enc, err := bson.NewEncoder(vw)
if err != nil {
panic(err)
}
enc.IntMinSize()
err = enc.Encode(foo{2})
if err != nil {
panic(err)
}
// Print the BSON document as Extended JSON by converting it to bson.Raw.
fmt.Println(bson.Raw(buf.Bytes()).String())
}