Wednesday, August 15, 2012

"datastore: invalid entity type"

The below error message is defined in datastore package of AppEngine.
ErrInvalidEntityType = errors.New("datastore: invalid entity type")
If by the accident one wrote:
data := Data{}
err := datastore.Get(c, key, data)

One will get above error message. The correct code looks as below:
data := Data{}
err := datastore.Get(c, key, &data)

The change is third passed parameter.

According to doc:
Get loads the entity stored for k into dst, which must be a struct pointer or implement PropertyLoadSaver.

1 comment: