From 25f8b5a07e73768a1e89cb7acc424cac0ff8f22f Mon Sep 17 00:00:00 2001 From: qydysky Date: Thu, 18 Apr 2024 16:23:05 +0000 Subject: [PATCH] 1 --- component2/comp.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/component2/comp.go b/component2/comp.go index 833fa71..93d632d 100644 --- a/component2/comp.go +++ b/component2/comp.go @@ -33,11 +33,12 @@ func Register[TargetInterface any](pkgId string, _interface TargetInterface) err return nil } -func Get[TargetInterface any](pkgId string, defaultInterface ...TargetInterface) (_interface TargetInterface) { +func Get[TargetInterface any](pkgId string, init ...func(TargetInterface) TargetInterface) (_interface TargetInterface) { if tmp, ok := pkgInterfaceMap[pkgId].(TargetInterface); ok { + for i := 0; i < len(init); i++ { + tmp = init[i](tmp) + } return tmp - } else if len(defaultInterface) > 0 { - return defaultInterface[0] } else { panic(ErrGet) } -- 2.39.2