程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了在Google App Engine中将reflect.Value传递到datastore.GetMulti大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决在Google App ENGIne中将reflect.Value传递到datastore.GetMulti?

开发过程中遇到在Google App ENGIne中将reflect.Value传递到datastore.GetMulti的问题如何解决?下面主要结合日常开发的经验,给出你关于在Google App ENGIne中将reflect.Value传递到datastore.GetMulti的解决方法建议,希望对你解决在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,请注明来意。
标签:在Google