datastore: fix bug in example
Fixes
@@ -205,22 +205,28 @@ Example code:
K *datastore.Key `datastore:"__key__"`
}
+ func main() {
+ ctx := context.Background()
+ dsClient, err := datastore.NewClient(ctx, "my-project")
+ if err != nil {
+ // Handle error.
+ }
+
k := datastore.NameKey("Entity", "stringID", nil)
e := MyEntity{A: 12}
- k, err = dsClient.Put(ctx, k, e)
- if err != nil {
+ if _, err := dsClient.Put(ctx, k, &e); err != nil {
// Handle error.
}
var entities []MyEntity
q := datastore.NewQuery("Entity").Filter("A =", 12).Limit(1)
- _, err := dsClient.GetAll(ctx, q, &entities)
- if err != nil {
+ if _, err := dsClient.GetAll(ctx, q, &entities); err != nil {
// Handle error
}
log.Println(entities[0])
// Prints {12 /Entity,stringID}
+ }
