From 456afab76f078ef58b7e5b3409acc6b3f71c5b79 Mon Sep 17 00:00:00 2001 From: Eric Schmidt Date: Wed, 26 Oct 2022 11:30:23 -0700 Subject: [PATCH] docs(firestore): adds emulator snippet (#6926) --- firestore/doc.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/firestore/doc.go b/firestore/doc.go index 1cb5ebf95e80..5197fe525fdf 100644 --- a/firestore/doc.go +++ b/firestore/doc.go @@ -247,5 +247,17 @@ directed to the emulator instead of the production Firestore service. To install and run the emulator and its environment variables, see the documentation at https://cloud.google.com/sdk/gcloud/reference/beta/emulators/firestore/. Once the emulator is running, set FIRESTORE_EMULATOR_HOST to the API endpoint. + + // Set FIRESTORE_EMULATOR_HOST environment variable. + err := os.Setenv("FIRESTORE_EMULATOR_HOST", "localhost:9000") + if err != nil { + // TODO: Handle error. + } + // Create client as usual. + client, err := firestore.NewClient(ctx, "my-project-id") + if err != nil { + // TODO: Handle error. + } + defer client.Close() */ package firestore