This project demonstrates an example implementation of Queryable Encryption for the MongoDB Golang driver. To learn more about Queryable Encryption, see the Queryable Encryption section in the Server manual.
The following sections provide instructions on how to set up and run this project.
To run this sample app, you first need to install the following dependencies:
- MongoDB Server version 7.0 or later
- Automatic Encryption Shared Library version 7.0 or later
- Golang v1.13 or later
- libmongocrypt v1.8.0 or later
For more information on installation requirements for Queryable Encryption, see Installation Requirements.
-
Copy the
env_template
file in the root of the project directory to a file named.env
. -
Replace the placeholder values in the
.env
file with your own credentials. -
Start a MongoDB replica set with three nodes.
Note: If you are using mtools, you can create a replica set by running the following command:
mlaunch init --replicaset --nodes 3
-
In the
queryable-encryption-tutorial.go
file, replace the value of<Your KMS Provider Name>
with the name of your KMS provider. -
From the project root, run the following build command which downloads the dependencies defined in the
go.mod
file:go get go-qe-tutorial
-
Run the following command to compile the application:
go build -tags cse
Note: The
cse
build tag specifies support for Client-Side Encryption.For more information on compatible package versions, see the Driver Compatibility Table.
-
Run the compiled app with the following command:
./go-qe-tutorial
-
If successful, the application will print the sample document to the console.