【发布时间】:2015-04-18 14:51:32
【问题描述】:
数据存储支持的类型列表不包含指针类型 (https://cloud.google.com/appengine/docs/go/datastore/reference)。
那么我如何才能表示一个可以并且有时应该为零的值呢?
例如,在以下结构中,我需要 DailyValuePercent 可以为 nilable 以明确表示缺少该值。
type NutritionFact struct {
Name string `datastore:",noindex" json:"name"`
DailyValuePercent int `datastore:",noindex" json:"dailyValuePercent"`
}
由于我不能使用 *int 作为数据存储的字段类型,那么如何表示可选值?
【问题讨论】:
标签: google-app-engine go google-cloud-datastore