I have datastore objects that look like:
created (timestamp)
guid (string)
details (string)
start (string)
end (string
Often, the details
, start
or end
are NULL
.
In Go, I am trying to do this:
type Edge struct {
created time.Time
details string `datastore: "details,omitempty"`
guid string `datastore: "guid,omitempty"`
start string `datastore: "start,omitempty"`
end string `datastore: "end,omitempty"`
}
for t := client.Run(ctx, q); ; {
var x Edge
key, err := t.Next(&x)
if err == iterator.Done {
break
}
if err != nil {
fmt.Printf("error caught: %v\n\n", err)
}
fmt.Printf("Key=%v\nEdge=%#v\n\n", key, x)
}
The output error is always something like:
error caught: datastore: cannot load field "guid" into a "main.Edge": no such struct field
Key=/edges,4503602429165568
Edge=main.Edge{created:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)}, details:"", guid:"", start:"", end:""}
When I search for that key in the datastore console, I see that guid
is a valid string
.
GetAll
gave me almost the same problem.
My questions are:
- I'm new to Go. Is there anything specific I'm doing wrong here? (Any typos would be Stackoverflow specific. Because I changed a few things here)
- Is there anyway to see what datastore is sending back to be before putting it in a struct?
- Some of the values will sometimes be
null
. Likestart
,end
anddetails
. Is that valid for astring
in a struct?
Thank you.