I have a struct:
type struct Foo {
Id ??
Name string
}
I get a list of Foos doing, where "c" is a NewContext():
q := datastore.NewQuery("Drug")
var foos []Foo
_, err := q.GetAll(c, &foos)
The Id is not populated, but the Name is. I'm trying to figure out how to get the Id to populate
The GetAll function returns a slice of the keys:
keys, err := q.GetAll(c, &foos)
The key for foos[i] is keys[i].
Use a loop to store the id in the entity if that's what you need:
for i := range keys {
foos[i].ID = keys[i].IntID() // or .StringID()
}