【发布时间】:2015-05-30 06:52:19
【问题描述】:
我在设计模型时遇到了一些问题, 因为我的模型包含一个切片,我得到一个错误
flattening nested structs leads to a slice of slices
设计这样的东西的最佳方法是什么
我更喜欢改变我的设计,而不是像这篇文章中建议的那样创建自己的序列化方法:
Loading datastore entities from Python project in Go leads to nested structs slices of slices error
type Inner2 struct {
Y float64
inner3 []Inner3
}
type Inner3 struct {
Z bool
}
type Outer struct {
A int16
I []Inner2
}
【问题讨论】:
-
stackoverflow.com/questions/25823186/… - 这里的方法建议在存储时将您的实体与 json 进行转换,这听起来对您有用。另外-stackoverflow.com/questions/20710802/…-这篇文章是在 python 的上下文中,但它是同样的问题。希望这些帮助。
-
@user3508122 我看到了这些帖子,但我不想编写自己的序列化方法。
-
Checkout PropertyLoadSaver cloud.google.com/appengine/docs/go/datastore/… 也许它可以提供帮助!
-
在链接的问题中,Guido van Rossum(Python 的创建者)很好地解释了问题的原因和替代方案。你不可能在这里得到更好的答案。
标签: google-app-engine go google-cloud-datastore google-cloud-storage