I have the following:
var s interface{} = new(MyStruct)
...
rt := reflect.TypeOf(s)
...
sf, err := rt.FieldByName("abc")
At Runtime, I get
panic: reflect: FieldByName of non-struct type
On further investigation, I noticed that my reflection type (rt above) is a Type for a pointer to MyStruct (ie *MyStruct), not MyStruct. Consequently, the code panics because I can't get the field name given a type of a pointer.
I've not been able to figure out how to actually get from a reflect.Type for *MyStruct to a reflect.Type for MyStruct. Please help.
------------------------------------------
PS in case this is pertinent, I used the following code to figure the above out. Please let me know if I'm misinterpreting it somehow.
fmt.Fprintf(os.Stdout, " #### Reflect Type: Of: ((%+v)) is: ((%+v)) with kind: ((%v))\n", s, rt, rt.Kind())
which printed out
#### Reflect Type: Of: ((&{ ... })) is: ((*MyStruct)) with kind: ((ptr))