You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
878 B
29 lines
878 B
// internal/core/discovery.go |
|
package core |
|
|
|
import ( |
|
"fmt" |
|
"reflect" |
|
) |
|
|
|
var moduleTypes []reflect.Type |
|
|
|
func RegisterModuleType(module Module) { |
|
fmt.Printf("🔍 注册模块类型: %T\n", module) |
|
moduleTypes = append(moduleTypes, reflect.TypeOf(module)) |
|
fmt.Printf("✅ 模块类型注册成功,当前注册的模块类型数量: %d\n", len(moduleTypes)) |
|
} |
|
|
|
func DiscoverModules(manager *ModuleManager) error { |
|
fmt.Printf("🔍 开始发现模块,当前注册的模块类型数量: %d\n", len(moduleTypes)) |
|
|
|
for i, typ := range moduleTypes { |
|
fmt.Printf("🔍 发现模块类型 %d: %s\n", i+1, typ.String()) |
|
module := reflect.New(typ.Elem()).Interface().(Module) |
|
fmt.Printf("✅ 创建模块实例: %s\n", module.Name()) |
|
manager.RegisterModule(module) |
|
} |
|
|
|
fmt.Printf("✅ 模块发现完成,总共发现 %d 个模块\n", len(moduleTypes)) |
|
return nil |
|
}
|
|
|