Issue with Go driver for client field encryption

Unfortunately, it’s not that simple. Files like mongo-go-driver/mongocrypt.go at master · mongodb/mongo-go-driver · GitHub need to be behind some sort of build flag or other build constraint. If they’re not, the #cgo lines will try to link against libmongocrypt, which will immediately fail if the user has not installed libmongocrypt on their system. The idea was to make users who wanted this feature opt-in via the build flag so that users who don’t need it didn’t have to install libmonogcrypt for no reason. Additionally, there are certain Docker images that don’t have cgo support at all, so it’s important that any cgo-based features in the driver are not automatically compiled.

For your point about always requiring compilation, I don’t think this is true. Both go run and go test support adding -tags cse command line option. We take advantage of this in many of our CI tasks, which call go test -tags cse ... rather than compiling anything.

1 Like