Code written around something like this is causing an issue:
func CreateNewItemOfType(returnType reflect.Type) (interface {}) {
return reflect.New(returnType).Interface();
}
... How can one actually return a struct of returnType
and not a pointer to a struct, as reflect
creates here? The compiler builds this fine but panics at run-time, yet will not accept an asterisk in front of the return call here in order to actually return the struct and not a pointer.
Aucun commentaire:
Enregistrer un commentaire