Google cloud platform `数据存储:无效的实体类型`datastore.NewQuery(";).祖先(myKey)中的`error``
我在我的go应用程序(下面的库版本)中使用Google cloud platform `数据存储:无效的实体类型`datastore.NewQuery(";).祖先(myKey)中的`error``,google-cloud-platform,go,google-cloud-datastore,Google Cloud Platform,Go,Google Cloud Datastore,我在我的go应用程序(下面的库版本)中使用“cloud.google.com/go/datastore”库,在使用祖先()查询时遇到错误数据存储:无效的实体类型 下面是我的方法调用: ctx := context.Background() client, err := datastore.NewClient(ctx, "MyProjectId", option.WithCredentialsFile(myJsonFile)) // ... err check ... myId := 112233
“cloud.google.com/go/datastore”
库,在使用祖先()
查询时遇到错误数据存储:无效的实体类型
下面是我的方法调用:
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 ...
但是,当我检查err
的值时,它是非nil
,并显示消息:datastore:invalid entity type
。当我进入云控制台并尝试我认为是等效的GQL(例如,SELECT*WHERE\uuuuuuu key\uuuuuuu有祖先键(MyKind,112233)
)时,它确实会在云控制台中返回结果
我也没有找到一种方便的方法来打印“cloud.google.com/go/datastore”
库中的调试信息,以查看它实际发送的内容,因此,如果您有任何帮助,我将不胜感激
有没有关于如何调试这个的想法,或者这是Go库中的一个问题?谢谢大家!
另外,这是我使用的“cloud.google.com/go/datastore”
版本:
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
上面的代码中有一个错误,它将双重引用传递给结构
c = &struct{ ... }
key, err := it.Next(&c)
实际上应该是:
c = &struct{ ... }
key, err := it.Next(c)
不幸的是,“Next”函数返回的是一个数据存储:无效的实体类型
,而不是更多的内容。。。有帮助的;)