Skip to content

Latest commit

 

History

History

Golang Queryable Encryption Tutorial

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.

Install Dependencies

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.

Configure Your Environment

  1. Copy the env_template file in the root of the project directory to a file named .env.

  2. Replace the placeholder values in the .env file with your own credentials.

  3. 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

Run the App

  1. In the queryable-encryption-tutorial.go file, replace the value of <Your KMS Provider Name> with the name of your KMS provider.

  2. From the project root, run the following build command which downloads the dependencies defined in the go.mod file:

    go get go-qe-tutorial
  3. 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.

  4. Run the compiled app with the following command:

    ./go-qe-tutorial
  5. If successful, the application will print the sample document to the console.