Skip to content

Commit 88d3716

Browse files
Move Go env setup code out of main app (#5504)
1 parent 757dd29 commit 88d3716

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

source/includes/qe-tutorials/go/queryable_encryption_helpers.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@ import (
88

99
"crypto/rand"
1010

11+
"github.com/joho/godotenv"
1112
"go.mongodb.org/mongo-driver/mongo"
1213
"go.mongodb.org/mongo-driver/mongo/options"
1314
)
1415

16+
func LoadEnv() {
17+
err := godotenv.Load(".env") // This file should contain your KMS credentials
18+
if err != nil {
19+
panic("Error loading .env file")
20+
}
21+
}
22+
1523
func GetKmsProviderCredentials(kmsProviderName string) map[string]map[string]interface{} {
1624

1725
switch kmsProviderName {

source/includes/qe-tutorials/go/queryable_encryption_tutorial.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,14 @@ import (
66
"fmt"
77
"os"
88

9-
"github.com/joho/godotenv"
109
"go.mongodb.org/mongo-driver/bson"
1110
"go.mongodb.org/mongo-driver/mongo"
1211
"go.mongodb.org/mongo-driver/mongo/options"
1312
)
1413

1514
func main() {
16-
err := godotenv.Load(".env") // This file should contain your KMS credentials
17-
if err != nil {
18-
panic("Error loading .env file")
19-
}
15+
16+
LoadEnv()
2017

2118
// start-setup-application-variables
2219
// KMS provider name should be one of the following: "aws", "gcp", "azure", "kmip" or "local"

0 commit comments

Comments
 (0)