I have two function in my code, a parent function with interface{}
parameter type and another child function with interface{}
parameter type.
I called childFunc
in parentFunc
and assert parent param to *interface{}
and pass it to childFunc
and at the end i called parent function with &user
argument
func childFunc(param interface{}){}
func parentFunc(param interface{}){
childFunc(*(param.(*interface{})))
}
parentFunc(&user)
but i have this error:
interface conversion: interface {} is *models.User, not *interface {}
what is the problem? how can i solve this problem?
this is my real code.
func Update(context echo.Context, modelUpdatedInstance interface{}, constraints map[string]interface{}) error {
/* Validation */
//test := modelUpdatedInstance.(*interface{})
_, validationErrors := govalidator.ValidateStruct(*(modelUpdatedInstance.(*interface{})))
if validationErrors != nil {
return validation.CheckValidation(context, validationErrors)
}
if constraints != nil {
database.DB.First(modelUpdatedInstance, constraints["id"]).Model(modelUpdatedInstance).Updates(modelUpdatedInstance)
} else {
return context.JSON(http.StatusBadRequest, map[string]interface{}{"Errors": []string{"no identifier"}})
}
return context.JSON(http.StatusOK, *(modelUpdatedInstance.(*interface{})))
}