316
return fmt.Errorf("task type %s must be struct or pointer to struct", rt.goType.String())
317
}
318
>
if _, ok := r.rtByGoType[rt.goType]; ok {
registry.go
319
return fmt.Errorf("task type %s is already registered", rt.goType.String())
320
}
321
>
if !(rt.componentGoType.Kind() == reflect.Interface ||
registry.go
322
>
(rt.componentGoType.Kind() == reflect.Struct ||
323
>
(rt.componentGoType.Kind() == reflect.Pointer && rt.componentGoType.Elem().Kind() == reflect.Struct)) &&
324
>
rt.componentGoType.AssignableTo(reflect.TypeFor[Component]())) {
325
return fmt.Errorf("component type %s must be and interface or struct that implements Component interface", rt.componentGoType.String())
326
}
327
329
>
r.rtByID[id] = rt
330
>
r.rtByGoType[rt.goType] = rt
331
>
return nil
332
}
333