Let's say I have a struct...
type Contact struct {
Id int `json:"id"`
FirstName *string `json:"firstname"`
LastName *string `json:"lastname"`
Email *string `json:"email"`
Phone *string `json:"phone"`
Ext *string `json:"ext"`
}
I define contact...
var contact Contact
I put a query from the db such as and populate contact if no errors were
returned...
err := q.Scan(&contact.Id, &contact.FirstName, &contact.LastName, &contact.
Email, &contact.Phone, &contact.Ext)
Problem is... later I use this contact for something else in my code, and
get a nil object exception for contact.Ext because it was nil in the db and
doesn't actually contain anything... not even a "".
How do I check this field for nil before processing it so I can handle it?
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.