Client
Firestore
Environment
gcloud beta emulators firestore start --host-port "localhost:8081"export FIRESTORE_EMULATOR_HOST=localhost:8081Code
client, err = firestore.NewClient(context.Background(),
"*detect-project-id*",
options...)
if err != nil {
return err
}
Expected behavior
By default, the client lib ignores the specified Firestore project ID in a NewClient() call when it detects an emulator is running (i.e. FIRESTORE_EMULATOR_HOST env var is set) ... unless the project ID is set to the "*detect-project-id*" sentinel value. It should check for the emulator env var before checking for the "*detect-project-id*" project ID sentinel value, and ignore this value in the same way as it ignores any other project ID value. Developers using the sentinel value to auto-detect projects when running their code in GCP should not need to modify their code/configuration to use a different project ID value when using the local emulator. (I'm guessing that was the intended behavior, since it is ignored for every other value.)
Actual behavior
When the sentinel value is used, the attempt to instantiate the client throws the following error:
firestore: see the docs on DetectProjectID
Screenshots
N/A
Additional context
None
I have submitted a pull request here that fixes this. It's been there for 4 days now and no comments, so I am not sure if I've done it right.
Thank you for sending it! I just responded on the CL, but I'd like to get one other review before merging.
Has there been any progress on this?
@rHermes apologies for the very belated response on this. @broady has a PR up with a fix if you'd like to take a look. #2598