GAE Go数据存储区-忽略一些变量?

Say I start by saving this structure into datastore:

type Foo struct {
    Important string
    NotImportant string
}

But later I decide that I don't really care for NotImportant anymore and would like to stop supporting it. The problem is, my datastore is already populated with data and I can't just drop it and replace the entire database with an updated structure. I know it is possible to create custom Load and Save methods like Load(c <-chan datastore.Property) error {, but that would require a lot of effort on a large struct.

Is there some easy way to tell Google App Engine Go datastore to ignore some variable when saving and not complain that the structure I'm loading the data into doesn't have the variable I don't care about any more?

See here: https://cloud.google.com/appengine/docs/go/datastore/reference Specifically the section on Properties.

type Foo struct {
    Important string
    NotImportant string `datastore:"-"`
}

That datastore:"-" bit is called a struct tag. They allow you to specify metadata about struct fields. A "-" means ignore this field. The Go spec discusses them here: https://golang.org/ref/spec#Struct_types

The encoding/json package (and many others) have similar tags.

You could do that

if err != nil && err != err.(*datastore.ErrFieldMismatch) {         
}