来自datastore.NewQuery(“”)。Ancestor(myKey)的“数据存储区:无效的实体类型”错误

I'm using the "cloud.google.com/go/datastore" library in my Go application (library version below), and am running into an error datastore: invalid entity type when I use the Ancestor() query.

Here's my method call:

ctx := context.Background()
client, err := datastore.NewClient(ctx, "MyProjectId", option.WithCredentialsFile(myJsonFile))
// ... err check ...
myId := 112233
myKey := datastore.IDKey("MyKind", myId, nil)

query := datastore.NewQuery("").Ancestor(myKey)    
it := client.Run(*ctx, query)
c = &struct{ ... }
key, err := it.Next(&c)
// ... err check ...

However, when I check the value of err, it's non-nil and has the message: datastore: invalid entity type. When I go into the cloud console and try what I think would be the equivalent GQL (e.g. SELECT * WHERE __key__ HAS ANCESTOR KEY(MyKind, 112233)), it does indeed return results in the cloud console.

I also didn't find a convenient way to print out debugging information in the "cloud.google.com/go/datastore" library to see what it's actually sending, so any help would be much appreciated there.

Any ideas on how I might debug this, or is it an issue in the Go library? Thank you!


P.S. Here's the "cloud.google.com/go/datastore" version I'm using:

commit f0afaf5fad3c46ae392ebab6b7553d37d65d07ac (HEAD -> master, origin/master, origin/HEAD)
Author: [redacted]
Date:   Thu May 31 13:15:30 2018 -0700

    oslogin: generate v1 client

    Change-Id: I515527be0e8acc1fe55cab969df9f76fd8d93b26

There's a bug in the code above which is passing a double reference to a struct.

c = &struct{ ... }
key, err := it.Next(&c)

Should actually be:

c = &struct{ ... }
key, err := it.Next(c)

Unfortunately the "Next" function returns a datastore: invalid entity type rather than something a little more... helpful ;)