I had created a basic structure,
type UpdateRequest struct {
UrID string `json:"urID"`
Ssn string `json:"ssn"`
ReqType string `json:"reqType"`
ReqValue string `json:"reqValue"`
CreatedAt string `json:"createdAt"`
LastModifiedAt string `json:"lastModifiedAt`
ActionTakenAt string `json:"actionTakenAt`
ReqStatus string `json:"reqStatus"`
}
For accessing each records for the above structure I created a function named as getFieldString which reads each fields from a structure individually
func getFieldString(e *Employee, field string) string {
r := reflect.ValueOf(e)
f := reflect.Indirect(r).FieldByName(field)
return f.String() }
So If i want to access Urid from the above structure I can just use
var ur UpdateRequest;
getFieldString(&ur,"Urid")
I have declared a new structure which has a String array.
type SSNList struct{ SSNArray []string }
I am having trouble retrieving the array object stored in a structure. Is there any other way instead of using Reflect and Indirect?