如何使用Golang将种子数据加载到App Engine的数据存储区中?

I need to create a dictionary table inside of datastore and I would like to be able to have the data seeded by a script. Is there an easy way of doing this using go?

Ideally I'd like to be able to add entries to a list of "names" and the script should go through the list check if dictionary table contains and entry with the name and if not it should create it. It would also be cool if it would run only on application restart.

So, to begin, I'll gently remind you that there are no "tables" in Datastore. Thinking using the terms of the RDBMS world will only confuse you. Please take the time to really understand the underlying storage mechanisms and data structures. I'd recommend this video for an in-depth look at what Datastore actually is.

So to get to your actual use-case, "application restart" is also something of a tricky term to use in relation to app engine. I'd recommend getting familiar with the actual infrastructure that runs your app - when instances of what scaling type are turned on and off, how they can communicate, etc...

The best way, apart from these nitpicks, to have the list of words ("Names") to check for stored in your datastore. A cron job at a given time interval would run and this code would fetch this archetypal list of Names. Then the code would initiate a task queue job to run the following process for that name: check if the name already has a user defined value in the "actual" data, and if so, just exit. If it doesn't exist, create it. When a user wants to actually define data on that name, the code that their request goes through would retreive that object, test for a flag to know whether it was created by the automated cron job's task queue or not, and take action accordingly. The best way to initially populate the archetypal list of Names that should be checked against would be to use a bulk upload from CSV using appcfg to populate. This feature is mostly undocumented and although not technically deprecated, might take some thinking to get working right.

Best of luck in your coding endeavours.