2
votes

I have a standard appengine + datastore app (not flex) built in golang using these APIs:

google.golang.org/appengine
google.golang.org/appengine/datastore

I'm trying to write a command-line tool in golang to do various batch things with the datastore, such as migrating data, running consistency checks and so forth. The cli tool uses this API:

cloud.google.com/go/datastore

I can get the cli tool to talk to my hosted appengine datastore, but I can't figure out how to get it to talk to the localhost dev_appserver.py datastore. The 1st call to datastore datastoreClient.GetAll(ctx, q, nil) always hangs.

I read some of the API code, and it looks like I need to set DATASTORE_EMULATOR_HOST to point to http://localhost:some_port, but I can't get this to work w/ any of the 3 servers that are started up by dev_appserver.py (ports 8000, 8080, 53536).

Am I on the right track? I've read a lot of posts & help, but they're either too old, or talk about appengine flex and so forth.

Thanks.

1

1 Answers

0
votes

You could always use the standalone Datastore emulator.

Install it:

gcloud components install cloud-datastore-emulator

Start the emulator (do this in a background shell, the command runs in the foreground):

gcloud beta emulators datastore start

And then setup the environment for your application by running:

$(gcloud beta emulators datastore env-init)

Then run your app, and it should pick up and connect to the Datastore emulator automatically.