I am writing a service for search functionality. when i am passing values in the body to get the specific record i am able to get it based on the struct value only for PHONE.
I am very new to golang.
i need to search the values using all the fields in the struct for ex.phone or firstname or lastname of the patientstruct
my struct is as below
type PatientEntity struct {
ID int64
FirstName string
LastName string
Phone string
}
my code is
func SearchPatientsHandler(res http.ResponseWriter, req *http.Request) {
patient := &PatientEntity{}
if err := json.NewDecoder(req.Body).Decode(patient); err != nil {
panic(err)
}
patients := []*PatientEntity{}
q := datastore.NewQuery(KINDPATIENT).Filter("FirstName =",patient.FirstName)
keys, err := q.GetAll(ctx, &patients)
if err != nil {
// Handle error
return
}
json.NewEncoder(res).Encode(patients)
}
i need to search with all the values of struct .how can i resolve.