1 回答
TA贡献1757条经验 获得超7个赞
c := appengine.NewContext(r)
//Retrieve the entity ID from the submitted form. Convert to an int64
entity_id := r.FormValue("entity_id")
entity_id_int, err := strconv.ParseInt(entity_id, 10, 64)
if err != nil {
fmt.Fprint(w, "Unable to parse key")
return;
}
//We manufacture a datastore key based on the Kind and the
//entity ID (passed to us via the HTTP request parameter.
key := datastore.NewKey(c, kind, "", entity_id_int, nil)
//Load the Entity this key represents.
//We have to state the variable first, then conduct the Get operation
//so the datastore understands the struct representing the entity.
var entity CustomStruct
datastore.Get(c, key, &entity)
- 1 回答
- 0 关注
- 177 浏览
添加回答
举报