大佬教程收集整理的这篇文章主要介绍了在Google App Engine中将reflect.Value传递到datastore.GetMulti,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我通过添加Interface()
到dstSlice
:
func GetStart(c appENGIne.Context, keys []*datastore.Key, dst interface{}) error{
v := reflect.ValueOf(dst)
dstSlice := v.Slice(0, 2)
return datastore.GetMulti(c, keys, dstSlice.Interface())
}
我有一个包装函数@H_300_3@mypkg.GetStart周围datastore.GetMulti
。包装函数的参数必须与相同appENGIne.GetMulti
。就dst
本例而言,我想获得的前两个实体。我的代码当前如下所示,但不起作用。datastore.GetMulti
产生错误datastore:
dst has invalid type
。
type myEntity struct {
Val Int
}
keys := []*datastore.Key{keyOne,keyTwo,keyThreE}
entities := make([]myEntity,3)
mypkg.GetStart(c,keys,enities)
我的@H_300_3@mypkg.GetStart代码如下:
func GetStart(c appENGIne.Context,keys []*datastore.Key,dst interface{}) error{
v := reflect.ValueOf(dst)
dstSlice := v.Slice(0,2)
return datastore.GetMulti(c,dstSlicE)
}
以上是大佬教程为你收集整理的在Google App Engine中将reflect.Value传递到datastore.GetMulti全部内容,希望文章能够帮你解决在Google App Engine中将reflect.Value传递到datastore.GetMulti所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。